Strilanc
Veteran Scripter
- Reaction score
- 42
I figured out how to get any building with a single unit type to automatically train units.
First, you need a hacky function to convert an ability command to an order, using custom text:
Then the auto-training part just searches for a 'train' type ability to use:
First, you need a hacky function to convert an ability command to an order, using custom text:
Trigger:
- Convert AbilCommand to Order
- Options: Function
- Return Type: Order
- Parameters
- abilcommand = No Ability Command <Ability Command>
- Grammar Text: Convert AbilCommand to Order(abilcommand)
- Hint Text: (None)
- Custom Script Code
- Local Variables
- Actions
- General - Return Order(lp_abilcommand)
Then the auto-training part just searches for a 'train' type ability to use:
Trigger:
- AutoTrain
- Events
- Unit - Any Unit Enters (Entire map)
- Unit - Any Unit training is Completed
- Local Variables
- i = 0 <Integer>
- Conditions
- ((Triggering unit) has AutoTrain) == true
- (Training queue Slots Used of (Triggering unit)) == 0
- Actions
- General - For each integer i from 1 to (Number of abilities on (Triggering unit)) with increment 1, do (Actions)
- Actions
- General - If (Conditions) then do (Actions) else do (Actions)
- If
- (Class of ((Triggering unit) ability i)) == Train
- Then
- Unit - Order (Triggering unit) to (Convert AbilCommand to Order(((((Triggering unit) ability i), 0)))) (Replace Existing Orders)
- Else
- If
- General - If (Conditions) then do (Actions) else do (Actions)
- Actions
- General - For each integer i from 1 to (Number of abilities on (Triggering unit)) with increment 1, do (Actions)
- Events