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

Checking for closest region

Status
Not open for further replies.

Ardenian

A

Ardenian

You would have to keep track of the orders of the unit.
I think hashtables would be a good solution. Then store a variable with the region the unit was ordered to move at and check if a unit stops moving ( I think there is a system in the spell section for this), then load the stored variable and order the unit to go there.

If you have a few unit I would recommend using indexed variables instead.

Is it for a TD ?
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
You would have to keep track of the orders of the unit.
I think hashtables would be a good solution. Then store a variable with the region the unit was ordered to move at and check if a unit stops moving ( I think there is a system in the spell section for this), then load the stored variable and order the unit to go there.

If you have a few unit I would recommend using indexed variables instead.

When the unit is ordered to move to a point, save that point as a variable, and when the unit stops, then order it to move to the variable point again and clear the leak.

I knew I had to use some type of Unit Event system, but I was unsure about how to approach the whole situation. If there are multiple units moving to multiple locations, how would I even start that?

Scenario:
Unit A entered Region 1 and is moving to Region 2.
Unit B entered Region 6 and is moving to Region 9.

Both Unit A & Unit B stopped moving. Order Unit A to move to Region 2 & Order Unit B to move to Region 9.​


Is it for a TD ?

It's more of a Castle Defense. There is a portion of the map that includes the units running through a gauntlet, so at that point it becomes a Tower Defense.
 

Ardenian

A

Ardenian

Well, using hashtables would solve the issue. Store every wave unit in the hashtable and the point where it is moving to and once it stops moving, then order it to move to the coordinates you load from the hashtable.
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
Well, using hashtables would solve the issue. Store every wave unit in the hashtable and the point where it is moving to and once it stops moving, then order it to move to the coordinates you load from the hashtable.

Ahh that makes sense. I've always been an index kind of guy :( looks like I'll be reading up on hashtable tutorials. Thanks Ardenian!
 

Ardenian

A

Ardenian

You are welcome. :)

Take some time for them and also search for threads outside of Hive, it is an advanced topic and not that easy to learn.
 
Status
Not open for further replies.
Top