• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Solved] Making All units unavailable at the start of the game.

Status
Not open for further replies.
Level 3
Joined
Oct 19, 2014
Messages
26
Hello, i could use some help, im making map, where you gonna be buying units from barracks, but i wanna make that after every round units in barracks will change, what i saw in LegionTD is that they make all units limited to 0 at the begining so you cant build any, altough the builder have all of them, and then it will unlock limit training for some random units at each round. I got that. but my problem is im not able to make all units unavailabe, i got them all in one Unit Type Variable, And then i have this
obrázek_2021-09-12_160158.png

But for some reason it just dont do anything, once i test i still have full barrack of random units. Im not sure if im using that trigger wrong or.. Just have no clue right now :D So if someone could give me hand i would appreciate it
 
Level 20
Joined
Feb 27, 2019
Messages
617
"Player - Limit training of Unit to 0 for Player" will make it so the builder cant construct that unit type and that buildings cant train any of that unit type.
Setting it to -1 allows for an infinity of those buldings to be constructed and units to be trained.

It does not affect units sold by the building.

I suppose you are not looking to limit "Max stock" of sold units to 0 but you want to limit which units are available in the barracks. My guess would be that youd have to remove all the current units sold from the barrack and then add a random amount of new units to be sold.

I saved this randomize trigger a while ago, maybe it will be useful.
JASS:
globals
    integer int
    integer count
    integer array values
endglobals

function InitValues takes nothing returns nothing    
    set int = 0
    loop
        exitwhen int > 73
        set values[int] = int
        set int = int + 1
    endloop
    set count = 74
endfunction

function PickRandomValue takes nothing returns integer
    local integer index = GetRandomInt(0, count - 1)
    local integer result = values[index]
    set values[index] = values[count - 1]
    set count = count - 1
    return result
endfunction
 
Level 3
Joined
Oct 19, 2014
Messages
26
"Player - Limit training of Unit to 0 for Player" will make it so the builder cant construct that unit type and that buildings cant train any of that unit type.
Setting it to -1 allows for an infinity of those buldings to be constructed and units to be trained.

It does not affect units sold by the building.

I suppose you are not looking to limit "Max stock" of sold units to 0 but you want to limit which units are available in the barracks. My guess would be that youd have to remove all the current units sold from the barrack and then add a random amount of new units to be sold.

I saved this randomize trigger a while ago, maybe it will be useful.
JASS:
globals
    integer int
    integer count
    integer array values
endglobals

function InitValues takes nothing returns nothing   
    set int = 0
    loop
        exitwhen int > 73
        set values[int] = int
        set int = int + 1
    endloop
    set count = 74
endfunction

function PickRandomValue takes nothing returns integer
    local integer index = GetRandomInt(0, count - 1)
    local integer result = values[index]
    set values[index] = values[count - 1]
    set count = count - 1
    return result
endfunction
Yeah i think we are on same page, just.. i have no clue what any of this mean :D
 
Level 20
Joined
Feb 27, 2019
Messages
617
Ignore the randomize functions i posted.

Lets take it from the beginning.
1. A regular peasant constructs buildings.
2. A regular human barracks trains units.
3. A regular mercenary camp sells units.
The action "Player - Limit training of Unit to 0 for Player" only applies to constructed buildings and trained units and not for sold units.

From what I am hearing from you, you are asking about the 3rd option, yet you confuse me a bit since I know there is no "building selling units" that changes units in legiontd the way you explained. Only the builder may change units (buildings constructed), which works perfectly with "Limit training of Unit to 0 for Player". To change units sold from "building selling units" my guess is that one would need to remove the current units from the "building selling units" and add the new units to the "building selling units". If one would want it to show 0 in stock my guess is that there is a dummy unit that is used with "Max stack" set to 0 or the "Max stack" of that original unit type is changed to 0 but I havent found an option to change "Max stack" of a unit type.
 
Last edited:
Level 3
Joined
Oct 19, 2014
Messages
26
Ignore the randomize functions i posted.

Lets take it from the beginning.
1. A regular peasant constructs buildings.
2. A regular human barracks trains units.
3. A regular mercenary camp sells units.
The action "Player - Limit training of Unit to 0 for Player" only applies to constructed buildings and trained units and not for sold units.

From what I am hearing from you, you are asking about the 3rd option, yet you confuse me a bit since I know there is no "building selling units" that changes units in legiontd the way you explained. Only the builder may change units (buildings constructed), which works perfectly with "Limit training of Unit to 0 for Player". To change units sold from "building selling units" my guess is that one would need to remove the current units from the "building selling units" and add the new units to the "building selling units". If one would want it to show 0 in stock my guess is that there is a dummy unit that is used with "Max stack" set to 0 or the "Max stack" of that original unit type is changed to 0 but I havent found an option to change "Max stack" of a unit type.
Yeah i guess i just confused you sorry, i mean barracks building units. Not selling anything. So when game starts, the barrack will be empty, after.. x seconds you will get few random units to buy. New round you will get again new set of units to buy from. I used the "Limit training of Unit to....:" But thats the thing, when i test, the barracks just have all units in it, becose nothing got set to that 0.
 
Level 20
Joined
Feb 27, 2019
Messages
617
Works fine for me.

  • LimitFootman
    • Events
      • Time - Elapsed game time is 10.00 seconds
    • Conditions
    • Actions
      • Set VariableSet UnitType = Footman
      • Player - Limit training of UnitType to 0 for Player 1 (Red)
      • Game - Display to (All players) the text: (String(UnitType))

You can make sure the correct unit is getting limited by displaying message ingame.
Can you take a screenshot of the units in the barracks ingame and post it?
 
Level 3
Joined
Oct 19, 2014
Messages
26
Works fine for me.

  • LimitFootman
    • Events
      • Time - Elapsed game time is 10.00 seconds
    • Conditions
    • Actions
      • Set VariableSet UnitType = Footman
      • Player - Limit training of UnitType to 0 for Player 1 (Red)
      • Game - Display to (All players) the text: (String(UnitType))

You can make sure the correct unit is getting limited by displaying message ingame.
Can you take a screenshot of the units in the barracks ingame and post it?
Oh yeah, like this, it works for me aswell with one unit, but i need to do this for 73 units right now :D .. So thats why i wanted to use for Each Interger A, thats whats not working. If i do it same as you for one unit, its working good. Thats the main thing why im bothering here you :D .. Im confused why it is not working, becose is basicly the same thing just in loop, and dont really wanna make XX triggers just for limiting unit.
 
Level 3
Joined
Oct 19, 2014
Messages
26
Where are you setting UnitAvailable? The variables are probably not set yet when you run the loop.
Yeah, and im done. I was like.. "Come on, i cant be that dumb, to make such a stupid mistake." Turns out.. There is not even event in Setting those varaibles.. So yeah now its working as it should. Thanks you guys. Appreciate the help.
 
Status
Not open for further replies.
Top