• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Limiting Training Que

Status
Not open for further replies.
Level 19
Joined
Jul 19, 2006
Messages
2,307
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.
 
Last edited:
Level 13
Joined
Nov 4, 2006
Messages
1,239
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
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
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.

Edit: Here we go!

You can read about the type integers table here
The Type integer - Wc3campaigns

In Object editor there are units ranged from
JASS:
Chr (char)         Hex (Hexadecimals)        Dec (Decimal: "unit order id")
Human
'H000' - 'Hzzz' -> 0x48303030 - 0x487A7A7A -> 1211117616 - 1215986298
'h000' - 'hzzz' -> 0x68303030 - 0x687A7A7A -> 1747988528 - 1752857210
Orc
'O000' - 'Ozzz' -> 0x4F303030 - 0x4F7A7A7A -> 1328558128 - 1333426810
'o000' - 'ozzz' -> 0x6F303030 - 0x6F7A7A7A -> 1865429040 - 1870297722
Undead
'U000' - 'Uzzz' -> 0x55303030 - 0x557A7A7A -> 1429221424 - 1434090106
'u000' - 'uzzz' -> 0x75303030 - 0x757A7A7A -> 1966092336 - 1970961018
Night Elf
'E000' - 'Ezzz' -> 0x45303030 - 0x457A7A7A -> 1160785968 - 1165654650
'e000' - 'ezzz' -> 0x65303030 - 0x657A7A7A -> 1697656880 - 1702525562
Neutral
'N000' - 'Nzzz' -> 0x4E303030 - 0x4E7A7A7A -> 1311780912 - 1316649594
'n000' - 'nzzz' -> 0x6E303030 - 0x6E7A7A7A -> 1848651824 - 1853520506

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

/Regards
 

Attachments

  • UnitQueueLimit.w3x
    18.4 KB · Views: 58
Last edited:
Status
Not open for further replies.
Top