• 🏆 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!

1 unit trained at a time.

Status
Not open for further replies.
Level 3
Joined
Feb 29, 2020
Messages
43
So i've been struggling with this issue of making it so my buildings only make one unit at a time, like warcraft 2 style.

I tried this - Limiting Training Que - but it's broken. For one its not aesthetically pleasing. The bigger problem is that by hitting the hotkey for the trained unit and quickly clicking on another building, say a farm for example, you can queue a unit and change target before the esc key is pressed. No good at all for what i'm looking for.

So i came up with a creative solution. I removed all trained units from the building tech tree, and replaced them with only sold units. So the town hall only sells peasants, and one peasant at a time, with a 10 second cool down timer. Then i used the value of movement height in the peasants and set it for ten. I did the same thing with all the units in my map, giving the buildings a selling cooldown and matching the movement height with the cooldown. Then I used this trigger.


trigger.png


It works super well and i'm proud of myself for my creative solution, and I could not be happier with the look and feel of it. The problem I now face is the sound. The sound for training completion is played the moment the hotkey to train(buy) is pressed, instead of when the cooldown ends and the unit is created.

Does anyone have a solution for how to stop the sound from playing, and to play the units default created sound after the timer expires?

edit - so i found a potential solution. Export the sound file, ad a delay before the start, and import the sound file. However this is a LOT of work. Hopefully someone has an easier solution.
 
Last edited:

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,657
You can do this to limit buildings from training more than 1 unit at a time:
  • Begins Training
    • Events
      • Unit - A unit Begins training a unit
    • Conditions
    • Actions
      • Unit Group - Add (Triggering unit) to TrainGroup
  • Issues Train Order
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • ((Triggering unit) is in TrainGroup.) Equal to True
    • Actions
      • Trigger - Turn off (This trigger)
      • Custom script: call IssueImmediateOrderById(GetTriggerUnit(), 851976)
      • Trigger - Turn on (This trigger)
  • Finishes Training
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
    • Actions
      • Unit Group - Remove (Triggering unit) from TrainGroup.
Keep in mind, the "Issues Train Order" trigger will fire when ANY "no target" order is issued by the unit. In most cases this problem won't come up but it's something to be aware of.

This will also restart the production of a training unit if you try to train a new one. An unfortunate side effect but overall it works.
 
Last edited:
Level 3
Joined
Feb 29, 2020
Messages
43
Thanks but while i'm waiting for my unit to finish training I'm spamming my hotkey to train the next unit. this isn't really functional for the kind of map I'm designing. My system works way better and looks way better, but it's just time consuming. If i cant find an easy fix ill just modify all my audio files for all my units. Thank you for the suggestion though.
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,657
An idea:
For each Structure/Unit have 2 Dummy versions. The Dummy unit has no Sound and is used only for purchasing. The Dummy structure can train units but is unselectable/hidden.

So when a player purchases the Dummy unit, order the Dummy structure to begin training the "real" version of said unit. This real version is the unit that the player will control.

This removes the need of that Wait in your trigger and allows you to use the standard Warcraft 3 sounds.

To trigger this you could use a Unit Indexer and link the Dummy Units to their Real Unit counterparts.

Edit:
Uploaded a map that you may find useful. In it you can queue up to 7 units but once the first unit finishes training the queue is cleared.
 

Attachments

  • Limit Training 2.w3m
    15.8 KB · Views: 14
Last edited:
Level 3
Joined
Feb 29, 2020
Messages
43
So this worked great, thanks for that. Now I am faced with another problem Ive been banging my head against the wall with. I went to add a second unit to the barracks, and a third, but it's not working :(
 
Level 3
Joined
Feb 29, 2020
Messages
43
Sorry i should have been more specific. I am training two units at the same time. I only want to be able to train one unit at a time. It's driving me nuts!!! I've been trying to figure it out all morning.
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,657
So unfortunately you can't "restock" a unit (you can with neutral buildings but it's a whole nother story) but you can refund it's gold/lumber cost and prevent it from being trained.

And here's the map.
 

Attachments

  • Training Dummy 2.w3m
    24.9 KB · Views: 17
Level 3
Joined
Feb 29, 2020
Messages
43
Sorry i hate to be a bother but I am not being clear. I want to add riflemen to my barracks for example. I dont want one barracks to be able to train both a riflemen and a footman at one time. I want for example 4 barracks all to be able to train at the same time. Just not one barracks training 2 at a time. Thanks so much for your help, if i could figure this out on my own i would.
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,657
Alright, this one works.

For your Dummy Units make sure:
-Your Dummy unit doesn't have Requirements
-Your Dummy unit doesn't have Sound enabled
-Your Dummy unit uses build time
-Your Dummy unit uses gold/lumber/food
-Your Dummy unit doesn't have any abilities that might cause problems when it gets removed

For your Real Units make sure:
-Your Real unit doesn't have Requirements
-Your Real unit uses stock/stock replenish
-Your Real unit uses ONLY food, not gold or lumber

Your Dummy Buildings train the units (build time).
Your Real Buildings sell the units (stock).

If you want to use this system for more than just a Barracks you will have to copy and paste the Build Barracks trigger and adjust it to work for your new building.
 

Attachments

  • Training Dummy 3.w3m
    25.8 KB · Views: 15
Last edited:
Level 3
Joined
Feb 29, 2020
Messages
43
Thanks for your help. I ended up scrapping the entire selling/buying units. It was too buggy and restrictive. I went with abilities based on summons instead and revamped the entire system . I used a bunch of your work though so thanks for the help.

Here is what I came up with so far. Again this is VERY early on in my mod and there is a ton of work to do. Right now there is only footman and rifleman using this system, but many more units will come. to make rifleman you must first build a lumber mill in the game.
 

Attachments

  • test.w3m
    272.5 KB · Views: 18

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,657
Edit:
I fixed some things in the system and I think it's a lot better. I attached the map.

There's some strange mechanics which may seem confusing at first, but if you follow all of the steps precisely than you will see that it's actually fairly simple.

How to add a unit to the system:

1) Create a new ability for your desired unit based on "Train Rifleman". Give it a unique base order id (different from your others) and set it's gold/lumber cost.

2) Set the abilities Missile Speed to match the unit's Index in SQ Setup Units (Example: UnitType[1] = Footman, so the Footman ability should have a Missile Speed of 1)

3) Set the abilities Priority For Spell Steal to match the trained unit's Food Cost

4) In the SQ Setup Units trigger, add the unit to the system increasing the Index by 1 (This is the Index that needs to match the abilities Missile Speed)

5) Add the Train ability to your structure

If your unit doesn't have any Requirements then you're finished, otherwise:

6) Create a new ability for your desired unit based on "Train Rifleman Req", add your Requirements to this ability

7) Add this new Train Requirement ability to your structure instead of the gold/lumber cost one (This replaces step 5)

8) Go to the Object Editor and add your new unit to the Requirement Checker's "Techtree - Unit's Trained" list

9) Copy and paste the "Setup Rifleman Requirements" trigger and modify it to work for your new unit. There are instructions in the trigger

Finished!

I had to add this weird Requirement Checker stuff because for whatever stupid reason you can't add Requirements to the "Charge Gold and Lumber" ability. So instead I have to use a separate ability for the Requirements and make this whole extra system around it.

Of course if you like your system better than no worries!
 

Attachments

  • Single_Queue_System_v.1.0.w3m
    26.1 KB · Views: 25
Last edited:
Level 3
Joined
Feb 29, 2020
Messages
43
Thank you my friend. I will make some adjustments to it for my mod to make it function a little differently, but I think between the two of us we have managed to create the perfect single queue unit system. Far superior to any that has been posted here so far. I made one very small final adjustment, but I think we should post it on resources with shared credit because surely other people will find this useful. Anyway, my final adjustment to make it look a little prettier :)
 

Attachments

  • Single_Queue_System_v.1.0.w3m
    27.6 KB · Views: 13
Level 3
Joined
Feb 29, 2020
Messages
43
one thing i would like to do that i am having a little trouble with for my mod. I would like it to only show the unit in the barracks once the tech type requirement has been met. For example, once i have built the smith, the rifleman shows up in the barracks, not before. I am sure i can figure it out, but you are much better at this than me and can probably do it like 2 seconds. Do you know of an easy way to do this? Thank you.


Edit - Nevermind. I figured it out. Here is my final product that I will be using in my mod. It's perfect for what i need and looks and plays flawlessly like it was built into a finished game. Thank you so very much for your help. It would have taken me weeks without your help to get to this point and would have been much more messy.

edit 2 - I found a bug on my bug fixer :(, working on it now.

Edit 3 - O.k now it works for real. Thanks so much for your help.

Edit 4 - found more bugs, fixed more bugs lol
 

Attachments

  • Single_Queue_System_v.1.0(3).w3m
    29.4 KB · Views: 11
Last edited:
Level 3
Joined
Feb 29, 2020
Messages
43
Sorry one last thing. I'm implementing this into my map and the one thing I can't figure out is how you got button position y to get to -11. It won't let me do that on my units. It's messing the whole system up. it only lets me go 0 1 or 2.
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,657
You need to enable this in your World Editor. Go to File/Preferences/General and check on "Allow negative real values in the Object Editor", while you're there I recommend turning on "Automatically create unknown variables" as well if you haven't already.

Once this is done you can Shift-Click any field in the Object Editor to set it's value to whatever you want, in this case a negative number.

Also, i'm a bit busy with bugs in my own map but i'll definitely take a look at your work when I have a chance.
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,657
I'm looking at your map and I see how I can expand on what you're doing and make this a lot easier for you. But I have a question, do you want me to disable the Train Footman/Train Rifleman/etc... abilities when you begin training a unit or do you want me to remove the abilities like you're doing now?

The difference would be that disabled abilities still have an Icon, it's just blacked out and can't be clicked. Where as removed abilities are completely gone.
 
Level 3
Joined
Feb 29, 2020
Messages
43
I want them completely gone. The same way it is now. Exactly as it functions now. I don't want the icon to appear at all until all the requirements are met, and I want all the icons to disappear once i begin training a unit.
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,657
Alright, finished up the new version. So there's a few more variables to setup but it seems to work pretty well. You shouldn't have to touch any of the triggers in the System Trigger folder, everything can be done in the Single Queue System folder (the first folder).

You can see how I added a Gryphon Aviary to the system. If you want to add a new Structure Type then copy and paste that trigger or copy and paste the Barracks Setup trigger and follow the instructions inside. Make sure to increase the "TotalStructureTypes" variable in the "SQ Setup" trigger to match how many different types of structures the system uses. At the moment the system uses 2, the Barracks and the Gryphon Aviary.
 

Attachments

  • Single_Queue_System_v.1.1.w3m
    36.4 KB · Views: 18
Level 3
Joined
Feb 29, 2020
Messages
43
You're awesome man. You take what i do and make it into this neat little package that is easy to modify and clean and understandable. It's an amazing system now very professional. Thanks so much for your help if there is anything i can do for you don't hesitate to ask.
 
Level 3
Joined
Feb 29, 2020
Messages
43
o.k what the hell my editor just randomly stopped letting me put negative values in button position y. I have the settings correct in preferences and everything and tried toggling it on and off and opening and closing the editor and everything. I can still put them in other fields just not button position y, doesn't let me do it for any units at all. Did they patch the editor last night and take this out or something?
 
Status
Not open for further replies.
Top