Page 1 of 1

Ways to simplify this trigger???

Posted: Mon Jun 20, 2011 6:59 pm
by BugMeNot

Code: Select all

P1
    Events
        Unit - A unit enters layer1 <gen>
    Conditions
        (Owner of (Triggering unit)) Equal to PlayNum[1]
        ((Unit-type of (Triggering unit)) Equal to Footman) or (((Unit-type of (Triggering unit)) Equal to Sniper) or (((Unit-type of (Triggering unit)) Equal to Mortar) or (((Unit-type of (Triggering unit)) Equal to Gyrocopter) or (((Unit-type of (Triggering unit)) Equal to Priest) or (((Unit-type of (Triggering unit)) 
    Actions
        Unit - Change ownership of (Triggering unit) to Player 11 (Dark Green) and Change color
        Unit - Order (Triggering unit) to Attack-Move To (Center of second <gen>)


This map will have many more units added and is a pain to keep updating condition so basically a general condition that will make action apply to all units

Re: Ways to simplify this trigger???

Posted: Tue Jun 21, 2011 7:27 am
by 3ICE
Unit classifications! Make all units you want the trigger to work for classified as "Ancient" and then use the condition: Unit is Ancient.

If you want it to apply to all units, why have a condition at all? You don't need to have a condition in every trigger. You can just leave it empty and it will work always. Conditions are used to restrict. For example to disallow some units.

Are you willing to move it to JASS? You can create condition functions in jass:

Code: Select all

function P takes unit u, player p returns boolean
if
    (Owner of u) Equal to p
    (Unit-type of u) Equal to Footman or Sniper or Mortar or Gyrocopter or Priest or...
then
    return true
else
    return false
endif
endfunction
Or JASSify the whole trigger:

Code: Select all

function Px takes nothing returns nothing
if
    (Owner of u) Equal to p
    (Unit-type of u) Equal to Footman or Sniper or Mortar or Gyrocopter or Priest or...
then
    Unit - Change ownership of u to Player 11 (Dark Green) and Change color
    Unit - Order u to Attack-Move To second
endif
endfunction
The above two functions are pseudocode, not real JASS.

p.s.: If you don't know how to use the [TRIGGER] tag, don't use it. Or click here to learn.

p.p.s.:
Topic title:
Ways to simplify this trigger???
should have been
Ways to simplify this trigger?
Please don't use three question marks, one is enough. Ask, do not demand.
(Three question marks mean you are demanding help and that is rude.)

Re: Ways to simplify this trigger???

Posted: Thu Jun 23, 2011 3:15 am
by BugMeNot
Ya the jass method would actually help. how do you alter it if you make the event and action same but make a condition like to exclude certain builders(around 5) and buildings? Basically in the map, the only change in ownership is units. It would be a perfect fit if you can make it only change all units except for builders and buildings. Also im not too great with jass, i understand what the trigger is doing in each line but wheres the region part?

Re: Ways to simplify this trigger???

Posted: Thu Jun 23, 2011 8:29 am
by 3ICE
Oh. You don't need JASS for that. Just two simple boolean conditions. Builders can be filtered out with: t_uni Unit - Unit classification is Worker and buildings in a similar way: t_uni Unit - Unit is a Building. Reverse them both (separately) with the t_if Not function available in conditions.