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

Units like in Legion TD

Status
Not open for further replies.
Level 4
Joined
Jan 3, 2012
Messages
60
Hey guys!

I know i already have asked this question before, but i didn't really got an answer.

How do i make the units move like in Legion TD? The units needs to be alive in the waves and then standing still between the waves. They also have to respawn if they die and when the wave is finish they all have to stand exactly where they were build.
It could be nice if someone will post the trigger or made a test map for me.
Thank you!
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
First, you need to make 2 different unit types for each unit.

One is a building, the other one is the actual fighter.

When the round starts, you need to put all of the buildings in a unit group, hide them, and spawn the corresponding fighter at its location.

At the end of the round, you need to pick every unit in the hidden group and unhide them.

AFAIK the last official version of LTD was open-source, so try find it and look at the triggers.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
I made this very quickly. The variable names are horrible, but you get the point.
I wanted to explain how this worked, but ruler beat me to it :).

Edit: It does have a few flaws by the way:
1) It doesn't recycle sold buildings. This is actually easy to add, but I wasn't in the mood to create a sell-ability. (Just do Set Unit/Building/Loc[SoldId] = Unit/Building/Loc[Count], Set Count = Count-1).
2) This doesn't really include upgrades. Works pretty much the same way though.
 

Attachments

  • Legion TD - Example.w3x
    18.5 KB · Views: 170
Level 4
Joined
Jan 3, 2012
Messages
60
Thank you guys!

I don't fully understand it so i have to ask a question.
I have some upgrades to the units aswell, but when i upgrade the buildings it's still spawning the non-upgraded unit. How do i fix this?
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
(OH, I forgot an action: set the custom value of the constructed structure to the unit count as well when creating the unit)

An upgrade works pretty much the same way as when you're constructing a building.
First, you remove the unit that belongs to that building ("Unit[Custom Value]").
You see which unit-type the newly upgraded one is (same loop as before, just change the condition slightly so it checks the triggering unit), then you create the unit that matches that unit-type in the correct location (Loc[custom value]) and set all the values correctly (hide / collision off / move / unit[value] / set custom value).
Then you skip the remaining actions.
The differences with the "Constructed structure"-trigger are that you remove the unit first and don't change any variables aside from the "Unit[Custom Value]" one.

Oh, you're going to use "Custom value of unit" a lot, so you might want to put that into a temporary variable.

Is this too cryptic, or can you get it to work?
 
Level 4
Joined
Jan 3, 2012
Messages
60
Im sorry, im not that good with triggers yet. It woould be very nice to have something look at. I will maybe be able to figure out how it works then. :)
Your help is much appreciated!
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
(OH, I forgot an action: set the custom value of the constructed structure to the unit count as well when creating the unit)

An upgrade works pretty much the same way as when you're constructing a building.
First, you remove the unit that belongs to that building ("Unit[Custom Value]").
You see which unit-type the newly upgraded one is (same loop as before, just change the condition slightly so it checks the triggering unit), then you create the unit that matches that unit-type in the correct location (Loc[custom value]) and set all the values correctly (hide / collision off / move / unit[value] / set custom value).
Then you skip the remaining actions.
The differences with the "Constructed structure"-trigger are that you remove the unit first and don't change any variables aside from the "Unit[Custom Value]" one.

Oh, you're going to use "Custom value of unit" a lot, so you might want to put that into a temporary variable.

Is this too cryptic, or can you get it to work?

I haven't looked at your triggers, but it sounds like you are using unit custom value to link a fighter type to a building type. Should you rather leave custom value for unit indexers, and use unit Point Value? Since Point Value is a unit-type value, it also makes it easier.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
I haven't looked at your triggers, but it sounds like you are using unit custom value to link a fighter type to a building type. Should you rather leave custom value for unit indexers, and use unit Point Value? Since Point Value is a unit-type value, it also makes it easier.
You're right: I made this knowing that it would mess with Unit Indexer. From the looks of it, he's not using Unit Indexer so I thought it wouldn't hurt.

Point values won't work because it has to be dynamic (5 units of the same type should have different values).
I can just use Unit Indexer though, or maybe with a hashtable.
Anyway, I used point values to link building-types with unit-types right now. It should make it easier if you've got many of them.

niller1414 said:
Im sorry, im not that good with triggers yet. It woould be very nice to have something look at. I will maybe be able to figure out how it works then. :)
Your help is much appreciated!
Certainly.
I just need to think on how I'm going to do this. Hashtables, maybe Unit Indexer? Also, the name. I have absolutely no idea how to name this system. Everything I can think of is horrible. I named the variables "Wave~" for now, but that's just misleading.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
ruler said:
Also, it doesn't need to be dynamic.
When a unit dies/gets upgraded, then a specific unit needs to get changed (the one linked with the dying/upgraded unit). Point values can't do this.
BUT you do have a point: I could link the unit-types and building-types together with point values!
However, because I didn't read your edit before now, I've made the system without that and I'm too lazy to change it :(

Attached the map, I hope it works correctly :D.
 

Attachments

  • Legion TD - Template.w3x
    20 KB · Views: 167
Level 4
Joined
Jan 3, 2012
Messages
60
This is great! Thank you for this wonderful system Ap0calypse, and thank you for your help.

+10000 rep to you! :)
 
Status
Not open for further replies.
Top