• 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!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

How to Make Units Autobuild in a Line

Status
Not open for further replies.
Level 4
Joined
Jul 14, 2012
Messages
100
Okay so If anyone's ever placed that game called genesis of empires, the one where you build roads to connect cities and whatnot, theyd know that your villager has an ability which, when pressed, requires that you target a location. He then autobuilds roads in the direction of the location, which must be cardinal(north, south, east, west).

I was wondering how they did that, and someone suggested I do something like that for this map im doing where walls can be constructed, so villagers can autobuild walls much easier, and make the game less micro-requiring.

Does anyone know how an ability like such works? I've considered possibilities of an invisible dummy unit being created at the target location but to build the walls, I have no clue.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Should the worker construct all the walls himself (Civilization-style, where a worker builds every road himself up to the point you chose), or should they all build at once (BFME2-style, where a wall will auto-construct itself to the target location).
And for your map, should it also only be a cardinal direction? (Or maybe diagonals are also allowed?)

I'll try to create such a system right now (I think I'll do cardinals-only, worker needs to build everything first, can change depending on what you want).
 
Level 4
Joined
Jul 14, 2012
Messages
100
My system would be cardinal only, and the worker would indeed need to construct each wall.

How would such a system be created? It seems complex, or at least with my limited knowledge of GUI
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Yeah, it just become more complex than I thought.
That's because there's no direct way to get the constructing unit (only the unit being constructed).

I've circumvented this by using orders: a human builder is ordered to "farm" when about to create a farm and from the moment he starts the building, he is ordered to "repair".
Thus if you check that the builder doesn't have any of those 2 orders, you can safely say that he can construct the next building in line.
I've saved all other information in a hashtable.


Use the "Build Wall" ability to auto-build, use the any other command to stop autobuilding.
 

Attachments

  • AutoBuild.w3x
    19.9 KB · Views: 39
Level 4
Joined
Jul 14, 2012
Messages
100
I seem to have some trouble merging the triggers into my map. I added all the variables you used, using their exact name and everything. But the triggers wont enable and I cant tell why. I barely understood half of your work ._.

Also, for my map theres 2 kinds of walls, Horizontal and Vertical, and 2 levels, the normal kind, and the Fortified kind.
I would imagine that even if your map did merge with mine, wouldnt it only build one of the wall types regardless of the direction of the wall? Vertical walls on a horizontal line would look funny...

Heres the map, if you can tell whats wrong with it.

View attachment The Human Race V0.7.1.w3x
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Edit: because of the big message, I split it into a few paragraphs so you can tl;dr if you'd like xD

Intro:
Here's a hint: if you go to File -> Preferences a menu will pop up with several tabs, in the "general" tab make sure the value "Automatically create unknown variables while pasting trigger data" is checked (enabled).
If that is enabled, all you have to do is copy the triggers (or even easier: the category the triggers belong to) and paste them in your map, all variables will automatically be created.
There is 1 noticeable exception: if that variable is only used in JASS (Custom script), on the same note a variable can have a different type than it actually has because it's used in a 'strange' way.
In this case, the problem is that you either forgot the variable "handleId", or that the world editor automatically created it as a handle variable (instead of a integer variable, which it should've been).
So adding the variable "handleId" with as type integer should do the trick.

How to solve the problem:
You're completely correct about the different types of walls :)
The order when constructing any custom building is "custom_RAWID".
To see the Raw ID of a unit, press CTRL + D in the object editor (the fortified walls are h00Q and h00H for example).
So in the trigger "Build Wall", you see the action "Set constructOrder = farm", that constructOrder should change depending on what direction you're casting the ability in and which unit is casting it (I believe that 1 unit cannot build both type of walls? Otherwise you'd have to create an extra ability).
The direction is "constructionAngle" (which is always a multiple of 90).

In any case, here's an example of how it should be changed:
if the builder is the industrial one and the direction is either 90 or 270, set constructOrder to "custom_h00Q", else set it to "custom_h00H".
Do the same for the other builder (but change the constructOrder of course).

I hope this makes sense. If you didn't understand this, I'd be glad to add it for you ^^


Unrelated
On an unrelated note, I'd like to congratulate you on your brilliant use of the object editor categories :)
I've been repeating it over and over again that units that belong to the same race should be in the same category, yet many people fail to do this.
So thank you for raising my hopes in that regard.

The triggers do need quite a lot of improvement though :p (some of them are nice, but others really aren't).
I actually believe you could combine all those alliance triggers into 1 trigger (which is, strangely enough, not even that much bigger than just 1 of those triggers if my brain is visualizing the trigger correctly).
But you didn't come here for that I guess.
 
Level 4
Joined
Jul 14, 2012
Messages
100
Oh wow I shouldve done that Preference thing then.. But with the walls, I'm still not quite following. I've never done anything close to the complexity of what youve done and all that confuses me.

Also, yes, the builder can build both horizontal and vertical walls. But not both wall types. The first type is the normal one, unlocked after a certain technology in the Medieval age. The second type is the fortified one, unlocked after another technology in the renaissance age.

I haven't edited the map since I uploaded it on here in case you could perform this because it seems out of my league. I spent the last 2 hours analyzing what you did and it still looks alien xD

Haha my categorizing? I just copied units from other units, so they retained their value of a race as Human. There are a few exceptions with some abilities that I copied from non-human races >.< Also some neutral hostile units that i left under the neutral hostile category. Additionally i put villagers/settlers under a different category than other human units because it was easier for me that way.

And yea I know my triggers arent the prettiest. It took me a whole day to do the Village Settling nicer. I used to have 102 If Then Elses... nastiest thing youd ever see. Not only that, but it leaked bad. Very, Very, Very Bad. So by mid-game, the game was already lagging like crazy. Thats why I had to redo it, when I finally began to understand Looping a bit. So now its much nicer :D But yea I'm still learnin and thats why my other triggers arent as neat as that one(and even that village settling trigger isnt the neatest trigger possible i bet)
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Oh wow I shouldve done that Preference thing then.. But with the walls, I'm still not quite following. I've never done anything close to the complexity of what youve done and all that confuses me.

Also, yes, the builder can build both horizontal and vertical walls. But not both wall types. The first type is the normal one, unlocked after a certain technology in the Medieval age. The second type is the fortified one, unlocked after another technology in the renaissance age.

I haven't edited the map since I uploaded it on here in case you could perform this because it seems out of my league. I spent the last 2 hours analyzing what you did and it still looks alien xD
That's okay, I've edited the system and attached it to my post :)
I also re-created the alliance system, but didn't actually test it so I just hope it works :D

Haha my categorizing? I just copied units from other units, so they retained their value of a race as Human. There are a few exceptions with some abilities that I copied from non-human races >.< Also some neutral hostile units that i left under the neutral hostile category. Additionally i put villagers/settlers under a different category than other human units because it was easier for me that way.
Yes, 'some' units have just retained their human race, but there are many which you've changed as well. And that is exactly what I'm talking about: most beginner map makers (I don't actually know if you're a beginner, so excuse me if that isn't true) do not change the race at all, let alone set it to campaign.
It looks a lot nicer like this.

And yea I know my triggers arent the prettiest. It took me a whole day to do the Village Settling nicer. I used to have 102 If Then Elses... nastiest thing youd ever see. Not only that, but it leaked bad. Very, Very, Very Bad. So by mid-game, the game was already lagging like crazy. Thats why I had to redo it, when I finally began to understand Looping a bit. So now its much nicer :D But yea I'm still learnin and thats why my other triggers arent as neat as that one(and even that village settling trigger isnt the neatest trigger possible i bet)
Oh, I thought you had some outside help with some triggers. Turns out you just engaged in the act of learning.
The "Settlers" trigger still leaks by the way:
  • Set TempLoc = (Position of (Triggering unit))
  • Unit - Remove (Triggering unit) from the game
  • Unit - Create 1 Chieftain's Hut for (Owner of (Triggering unit)) at TempLoc facing Default building facing degrees
  • Set TempLoc = (Position of (Last created unit))
This leaks the "Position of (Triggering Unit)"
Every time you change the variable, you should remove the contents first.

Also, remove all
  • Do nothing
It's a trigger which calls nothing. Waste of productivity :)
 

Attachments

  • The Human Race V0.7.1.w3x
    4.2 MB · Views: 70
Level 4
Joined
Jul 14, 2012
Messages
100
Awesome! The walls work perfectly and as intended! ap0calypse, you have truly done a great service! :D

As for the ally system, I'll just have to wait and see if it works in my next public testing. Thanks so much for everything though, ap0calypse. I am still studying your work
 

Ralle

Owner
Level 79
Joined
Oct 6, 2004
Messages
10,183
I thought about a way of doing this. Is it not possible to make a unit that can only walk on buildable ground? If you created this unit (invisible) and made it walk to the destination, it would walk on the path where the road should be. Then you could track the unit and have the path you want your builder to follow when building.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Awesome! The walls work perfectly and as intended! ap0calypse, you have truly done a great service! :D

As for the ally system, I'll just have to wait and see if it works in my next public testing. Thanks so much for everything though, ap0calypse. I am still studying your work
You're welcome. I hope the ally system works and if not... well, I didn't remove the old system for a reason :)
I love the idea of the map, so good luck with that.

I thought about a way of doing this. Is it not possible to make a unit that can only walk on buildable ground? If you created this unit (invisible) and made it walk to the destination, it would walk on the path where the road should be. Then you could track the unit and have the path you want your builder to follow when building.
That is actually an interesting idea. Not so much for a wall (as the walls block the pathing of that unit), but could work for roads.
However, I don't actually know if a unit can only move on buildable terrain as unbuildable is, by default, also walkable. That doesn't mean it's impossible , I just don't directly know how to fix that issue :/
 
Level 4
Joined
Jul 14, 2012
Messages
100
The ally system didnt fully work for all the players, and it gave vision to allies, when I had intended vision to also be researched separately. But thanks for the concept of how you did the allying :D

And thanks mostly for the autobuild :) Really really appreciate it
 
Status
Not open for further replies.
Top