Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
Question: I want to be able to limit my training que to a maximum of five units. I know there is triggering involved, but I am very unclear on how it is that you go about doing this.
Extras: If you could provide me with a standard human training que with only five units instead of seven, that would be greatly appreciated.
so, you want to be able to produce more then five units, but only have five in the training queue at a time? i don't know if there is a way to get the order which detects when you enqueue a unit, but even then i can't find an action to remove the last unit in the queue, so i don't think its possible, at least in GUI
You can check when a unit trains a unit. You can also check when it is canceling the last one in the queue. If you press Escape in game, you order the unit to remove the last queued unit.
As for the triggers, I am working on it. The thing which takes time is that I have to convert hex to decimals to make sure it is defining train unit order, not an ability.
Now, if we look at the Dec column, this is the same as the UnitTypeid the trained unit has. (when you order a unit to train a unit, OrderId == UnitId.)
The thing we should do is to create a condition so that the issued order is any of these.
Hah, I found that there is no need for you to know anything about these hex and dec ids. the UnitType Char Id is enough,
since its the same integer just in different disguises, and wc3 reads them all anyways.
Back to the triggering, what do we need?
<> Condition when a structure is issued an order which is a train unit order.
<> A dummy ability (instead of custom value) with the level range of 7
<> An increament trigger which is setting the dummy ability to the amount of units in the queue.
<> A decreament trigger which is resetting when a unit is trained/canceled.
Since I do not know if the system shall be in Gui or Jass, I've decided to do both. The condition I told you needs to be in Jass.
The rest is fine in Gui.
For the the condition, this is what we could do:
JASS:
library IsTrainOrder
globals
integer array TrainOrderIdMin
integer array TrainOrderIdMax
endglobals
function OrderIsUnitTypeId takes integer orderid returns boolean
local integer i = 0
loop
exitwhen i == 10
if (orderid >= TrainOrderIdMin[i] and orderid <= TrainOrderIdMax[i]) then
return true
endif
set i = i+1
endloop
return false
endfunction
//===========================================================================
function InitTrig_IsTrainOrder takes nothing returns nothing
set TrainOrderIdMin[0] = 'E000'
set TrainOrderIdMin[1] = 'e000'
set TrainOrderIdMin[2] = 'H000'
set TrainOrderIdMin[3] = 'h000'
set TrainOrderIdMin[4] = 'N000'
set TrainOrderIdMin[5] = 'n000'
set TrainOrderIdMin[6] = 'O000'
set TrainOrderIdMin[7] = 'o000'
set TrainOrderIdMin[8] = 'U000'
set TrainOrderIdMin[9] = 'u000'
set TrainOrderIdMax[0] = 'Ezzz'
set TrainOrderIdMax[1] = 'ezzz'
set TrainOrderIdMax[2] = 'Hzzz'
set TrainOrderIdMax[3] = 'hzzz'
set TrainOrderIdMax[4] = 'Nzzz'
set TrainOrderIdMax[5] = 'nzzz'
set TrainOrderIdMax[6] = 'Ozzz'
set TrainOrderIdMax[7] = 'ozzz'
set TrainOrderIdMax[8] = 'Uzzz'
set TrainOrderIdMax[9] = 'uzzz'
endfunction
endlibrary
And then we use it the increament trigger:
Increase Training
Events
Unit - A unit Is issued an order with no target
Conditions
((Triggering unit) is A structure) Equal to True
Actions
Custom script: if OrderIsUnitTypeId( GetIssuedOrderId() ) then
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of Unit Queue Custom Value () for (Triggering unit)) Greater than 0
Then - Actions
//Game - Display to (All players) the text: Checking
//Game - Display to (All players) the text: Increase Queue
Unit - Set level of Unit Queue Custom Value () for (Triggering unit) to ((Level of Unit Queue Custom Value () for (Triggering unit)) + 1)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of Unit Queue Custom Value () for (Triggering unit)) Greater than 5
Then - Actions
//Game - Display to (All players) the text: Error: Cannot train...
For each (Integer A) from 1 to ((Level of Unit Queue Custom Value () for (Triggering unit)) - 5), do (Actions)
Loop - Actions
Game - Force (Owner of (Triggering unit)) to press Escape/Cancel
Else - Actions
Else - Actions
Unit - Add Unit Queue Custom Value () to (Triggering unit)
//Game - Display to (All players) the text: Added Queue
Custom script: endif
The decreament trigger was easier well ._.
Decrease Training
Events
Unit - A unit Cancels training a unit
Unit - A unit Finishes training a unit
Conditions
((Triggering unit) is A structure) Equal to True
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of Unit Queue Custom Value () for (Triggering unit)) Equal to 1
Then - Actions
Unit - Remove Unit Queue Custom Value () from (Triggering unit)
//Game - Display to (All players) the text: Removed Queue
Else - Actions
//Game - Display to (All players) the text: Decreased Queue
Unit - Set level of Unit Queue Custom Value () for (Triggering unit) to ((Level of Unit Queue Custom Value () for (Triggering unit)) - 1)
Well, sorry for the late response and well, it could be tricky to understand perhaps, I dont know... And well, if you need it in Jass, I can still help you know.
I've attached a test map as well, and I couldn't see any problems
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.