A barracks train a unit after 500 mana

Level 2
Joined
Apr 16, 2026
Messages
2
I searched for about an hour but didn't succeed. Maybe I ask to much for the Editor.

  • Let's say I want a barracks to train automatically a footman or to create a footman after having gain 500 mana. This barracks is not yet created.

( I probably have a variable problem but there doesn't seem to be the variable I want. I don't have Reforged. )
Thanks to whoever finds the answer. Have a good day. :peasant-smile:
 
You don't need Reforged or anything like that. You just need to track a newly created unit. A Barracks in this case is a building that you construct using Workers so it uses the "A unit Begins/Finishes/Cancels construction" Events. From there you need to track it over time so that you can continuously check it's current state - it's mana in this case. One way of doing that is using a Unit Group variable, which let's you easily track any number of Units at a time and interact with all of them whenever you'd like. Here's some rough draft triggers:

TRIGGER 1:
Events: Unit - A unit Finishes construction
Conditions: (Unit-Type of (Constructed structure)) Equal to Barracks
Actions: Unit Group - Add (Constructed structure) to Barracks_Group

TRIGGER 2:
Events: Time - Every 0.10 seconds of game time
Conditions:
Actions: Unit Group - Pick every unit in Barracks_Group and do Actions...


Trigger 2 would then need to use an If Then Else action to check the current mana of the (Picked unit). If it's Mana is >= 500 then proceed to Ordering the (Picked unit) to Train a Footman, or just Create one instantly. You can also subtract 500 Mana from the Barracks to restart the process. Lastly, you'll want to Remove any dead Barracks from the Unit Group, otherwise you'll be trying to interact with Barracks that "no longer exist".
 
Last edited:
Capture d'écran 2026-04-22 230403.png
Capture d'écran 2026-04-22 230412.png

It wasn't worked with the variable but at least it's worked anyway... Thanks a lot ! :peasant-thumbs-up:
It's easy in a way, but you have to speak the game's language. Two hours for that. :peasant-work-work:
 
The Unit Group variable works, you probably just need to do this:
  • Events
    • Time - Elapsed game time is 0.00 seconds
  • Conditions
  • Actions
    • Set Variable caserne = (Units of type Caserne)
This will keep track of any Barracks (Caserne) that already exist. Remember, your other trigger only works when they're CONSTRUCTED, which means a Worker like a Peasant has to finish building them.

Also, here's how you can remove the unit from the caserne Unit Group. A good time to do it is when the building dies:
  • Events
    • Unit - A unit Dies
  • Conditions
    • (Unit-type of (Dying unit)) Equal to Caserne
  • Actions
    • Unit Group - Remove (Dying unit) from caserne
Then you can go back to using the Unit Group variable. Also, you need to use Pick Every Unit only once:
  • Actions
    • Unit Group - Pick every unit in caserne and do (Actions)
      • Loop - Actions
        • If (All conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Mana of (Picked unit)) Greater than or Equal to 500.00
          • Then - Actions
            • Unit - Order (Picked unit) to train/upgrade to a Fantassin
            • Unit - Set mana of (Picked unit) to 0.00
          • Else - Actions
Anything you do to the (Picked unit) will happen to ALL units inside of the Unit Group.
 
Last edited:
Back
Top