To prevent one barrack hoging all the queue, extend your requirement to also require CountOfUnit(Marine,QueuedOrBetterAtUnit) == 0 (not quite syntax again). That will ensure a barrack will not be able to queue a marine if it already has one in the queue or building.
The training bar depends on another ability of type "queue", you can define if it's visible and so on.
a) Create a new behavior of type "buff".
b) Set behavior's period to 0.25 (or so), call the periodic effect created next step.
c) Create an effect type Issue Order, set ability to your train command, set Unit to "Source".
d) Create a new requirement for CountOfUnit(Marine) < CountOfUnit(Barracks)*4 (not quite the syntax, but you get the idea)
e) Set the train ability (new one, or a modified existing one) to take that requirement we just created to train more marines.
That's the big picture, you should manage to fill in the details, ask for more details about any specific part otherwise.
Are you sure you want to use triggers? This can be done entirely in data.
You can use a behavior with a periodic effect issuing order to train units, while the Train ability has a requirement that requires the count of marines (QueuedOrBetter) to be less than 4 * barracks to allow training.
I would really implement that kind of stuff in data rather than triggers. Triggers is best used for "higher level" stuff.
To prevent one barrack hoging all the queue, extend your requirement to also require CountOfUnit(Marine,QueuedOrBetterAtUnit) == 0 (not quite syntax again). That will ensure a barrack will not be able to queue a marine if it already has one in the queue or building.
The training bar depends on another ability of type "queue", you can define if it's visible and so on.
a) Create a new behavior of type "buff".
b) Set behavior's period to 0.25 (or so), call the periodic effect created next step.
c) Create an effect type Issue Order, set ability to your train command, set Unit to "Source".
d) Create a new requirement for CountOfUnit(Marine) < CountOfUnit(Barracks)*4 (not quite the syntax, but you get the idea)
e) Set the train ability (new one, or a modified existing one) to take that requirement we just created to train more marines.
That's the big picture, you should manage to fill in the details, ask for more details about any specific part otherwise.
Are you sure you want to use triggers? This can be done entirely in data.
You can use a behavior with a periodic effect issuing order to train units, while the Train ability has a requirement that requires the count of marines (QueuedOrBetter) to be less than 4 * barracks to allow training.
I would really implement that kind of stuff in data rather than triggers. Triggers is best used for "higher level" stuff.