I started making a map and, before becoming extremely discouraged by obstacles like the popularity system (meaning I can't do random playtests), I made an autotraining system better than the stuff in the maps I've seen.
How is it better? Well:
Doesn't periodically queue units, which is nice because it doesn't force players to empty the ever-filling queue in order to do actions like research upgrades.
Independent of unit type. You don't have to make changes every time you add or modify a building, just give the building a behavior.
Simple to understand. Autotrain buildings start training something as soon as they are constructed, and requeue anything that finishes. That's it.
In any case, I thought I should dump it somewhere. The hard part was writing an "Issue Unit Training Order" action, and the rest is just topping. I'm actually not sure how to export it in a usable format.
Triggers follow.
**Issue Unit Training Order**
Options: Action
Return Type: (None)
Parameters
trainer = No Unit <Unit>
primaryType = No Game Link <Game Link - Unit>
Grammar Text: Order (trainer) to train a unit of type (primaryType)
Hint Text: Orders a unit to begin training a particular unit type.
Custom Script Code
Local Variables
abilIndex = (Get Training Ability Index(trainer)) <Integer>
commandIndex = 0 <Integer>
itemIndex = 0 <Integer>
availableSlotCount = (Training queue Slots Available of trainer) <Integer>
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
availableSlotCount == 0
Then
General - Skip remaining actions
Else
General - For each integer commandIndex from 0 to 29 with increment 1, do (Actions)
Actions
Unit - Order trainer to (Ability Command to Order((((trainer ability abilIndex), commandIndex)))) (Replace Existing Orders)
General - If (Conditions) then do (Actions) else do (Actions)
If
(Training queue Slots Available of trainer) < availableSlotCount
Then
General - For each integer itemIndex from 1 to (Number of items in trainer training queue slot ) with increment 1, do (Actions)
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Unit type of trainer training queue slot (Training queue Slots Used of trainer) item itemIndex) == primaryType
Then
General - Skip remaining actions
Else
Order (trainer) to cancel its last queued training order
Else
**Ability Command to Order**
Options: Function
Return Type: Order
Parameters
abilcommand = No Ability Command <Ability Command>
Grammar Text: Ability Command to Order(abilcommand)
Hint Text: Converts an ability command to an order.
Custom Script Code
Local Variables
Actions
General - Return Order(lp_abilcommand)
**Get Training Ability Index**
Options: Function
Return Type: Integer
Parameters
trainer = No Unit <Unit>
Grammar Text: Get Training Ability Index(trainer)
Hint Text: Returns the index of a unit's training ability, or -1 if there is no such ability.
Custom Script Code
Local Variables
abilIndex = 0 <Integer>
Actions
General - For each integer abilIndex from 0 to (Number of abilities on trainer) with increment 1, do (Actions)
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Class of (trainer ability abilIndex)) == Train
Then
General - Return abilIndex
Else
General - Return -1
**Cancel Last Queued Training Order**
Options: Action
Return Type: (None)
Parameters
trainer = No Unit <Unit>
Grammar Text: Order (trainer) to cancel its last queued training order
Hint Text: Orders a unit to cancel the last training order in its queue.
Custom Script Code
Local Variables
i = 0 <Integer>
Actions
General - For each integer i from 1 to (Number of abilities on trainer) with increment 1, do (Actions)
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Class of (trainer ability i)) == Queue
Then
Unit - Order trainer to (Ability Command to Order((((trainer ability i), 0)))) (Replace Existing Orders)
Else
**Issue Any Training Order**
Options: Action
Return Type: (None)
Parameters
trainer = No Unit <Unit>
Grammar Text: Order (trainer) to train something arbitrary.
Hint Text: Orders a unit to begin training one of the things it can train.
Custom Script Code
Local Variables
abilIndex = (Get Training Ability Index(trainer)) <Integer>
Actions
Unit - Order trainer to (Ability Command to Order((((trainer ability abilIndex), 0)))) (Replace Existing Orders)
**On Enter Map**
Events
Unit - Any Unit Enters (Entire map)
Local Variables
Conditions
((Triggering unit) has AutoTrain) == true
Actions
Order ((Triggering unit)) to train something arbitrary.
**On Constructed**
Events
Unit - Any Unit construction progress is Completed
Local Variables
Conditions
((Triggering progress unit) has AutoTrain) == true
Actions
Order ((Triggering progress unit)) to train something arbitrary.
**On Training Complete**
Events
Unit - Any Unit training progress is Completed
Local Variables
Conditions
((Triggering unit) has AutoTrain) == true
curTrainer != (Triggering unit)
Actions
------- The curTrainer stuff is necessary to avoid double-queueing when training multi-spawn-units (like zerglings), which trigger the training event multiple times.
Variable - Set curTrainer = (Triggering unit)
Order ((Triggering unit)) to train a unit of type ((Triggering progress unit type))
**Clear Training Complete**
Events
Unit - Any Unit training progress is Started
Local Variables
Conditions
((Triggering unit) has AutoTrain) == true
Actions
Variable - Set curTrainer = No Unit
I didn't want to post something useless into the resources section.
The cancel last queued function is used by the other actions. You can't know the unit type you are queuing until after-the-fact, so the system works by doing add-check-oops-cancel add-check-oops-cancel add-check-yay!
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I started making a map and, before becoming extremely discouraged by obstacles like the popularity system (meaning I can't do random playtests), I made an autotraining system better than the stuff in the maps I've seen.
How is it better? Well:
In any case, I thought I should dump it somewhere. The hard part was writing an "Issue Unit Training Order" action, and the rest is just topping. I'm actually not sure how to export it in a usable format.
Triggers follow.
<<reply 208370="">>
I didn't want to post something useless into the resources section.
The cancel last queued function is used by the other actions. You can't know the unit type you are queuing until after-the-fact, so the system works by doing add-check-oops-cancel add-check-oops-cancel add-check-yay!