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

Calculate Nearest Unit

Status
Not open for further replies.
Level 5
Joined
May 27, 2007
Messages
162
Still doesn't work?

My bad, helps to run the right map.

Thanks. I need to spread some reputation around before I can boost yours Pharaoh_.

I'll try to dissect what you've changed and emulate it so the Miner attack moves to the nearest Asteroid after returning to the Processing Unit.

But - you see, the way it works now is that whenever the asteroid takes damage from a miner, he goes immediately to the nearest processor.. The idea is that a player can harvest asteroids for a while and then send them home to avoid a threat, instead of constantly going back and forth...

Ironed out that problem, now to recreating it :D
 
I wouldn't post it, if it didn't work. Do you want me to send a replay to you? :p

Ok.

Edit: What I've changed:
Made a simple GUI damage detection system and removed the attack detection you had, because that event mostly refers to the animation of attacking and not the action itself. So, the unit would end up standing there, instead of showing the sfx on the Asteroid.
I also added the Asteroids in a unit group, to refer to them, when I wanted to get the closest unit.
I also increased the radius of 512.00 to 99999.00 to get the nearest unit. I fixed some leaks that were involved with the triggers I edited (didn't check the map itself).

Your work: You need to change the trigger "GoldReturning", so that it refers to multiple units at a time. To do that, add the action in the Map Initialization within the Pick group that picks every Asteroid unit: Trigger - Add to GoldReturning <gen> the event (Unit - A unit comes within 256.00 of (Picked unit)). Remove afterwards the event from the GoldReturning trigger and leave the conditions and actions untouched.

Edit2:
Cardinian said:
But - you see, the way it works now is that whenever the asteroid takes damage from a miner, he goes immediately to the nearest processor.. The idea is that a player can harvest asteroids for a while and then send them home to avoid a threat, instead of constantly going back and forth...
I thought you wanted a simple imitation of resources. I don't really get what you now want actually.
 
Level 13
Joined
Sep 14, 2008
Messages
1,407
Oh my god... He actually figured it out -.- and that so fast... you know I start to hate you Pharao ;) you keep doing better than me :(

Maybe I can help you understand it:

Have you played Age of Empire 1/2/3/4 whatever before?

It works like the unit hits the goldmine and collects gold. (like trees in wc3) and after it got enough it returns to the outpost. He wants that with his asteroids.

Well gj for helping that guy.. I couldn't figure it out myself -.-
 
Level 5
Joined
May 27, 2007
Messages
162
haha, well, what I want is for a unit to attack/damage another unit and get his custom value increased. When his custom value hits a certain number, then this should trigger the automatically go to nearest.

The end product of this map, (probably v1.00 released when Warcraft IV comes out...) is that resources are randomly (over time and in some areas more than in others) created on the map. Your job is to harvest them, and protect your harvesters with other craft.

It is for that reason, that when a harvester is full it should automatically return home. But, most likely (7 times out of 10) you will be harvesting asteroids under threat, and will have to manually order them to go home regardless of whether or not they are full.

Anyways it is getting late, i'll try see what I can do now - and thanks again :)
 
Well, upon damage, in the trigger "Returning gold", increase the custom value of the unit by 1 and check when it hits X amount.
  • ReturningGold
    • Events
    • Conditions
      • (Unit-type of (Damage source)) Equal to Asteroid Miner
      • (Unit-type of (Triggering unit)) Equal to Asteroid
    • Actions
      • Unit - Set custom value of (Damage source) to ((Custom value of (Damage Source)) + 1)
      • If (All conditions are true) then do (Actions) else do (Actions)
        • If - Conditions
          • (Custom value of (Damage source)) Equal to X
        • Then - Actions
          • Set Distance = 9999999.00
          • Set Points[1] = (Position of (Triggering unit))
          • Unit Group - Pick every unit in ReturnResource and do (Actions)
            • Loop - Actions
              • Set Points[2] = (Position of (Picked unit))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Distance between Points[1] and Points[2]) Less than or equal to Distance
                • Then - Actions
                  • Unit - Order (Damage source) to Right-Click (Picked unit)
                • Else - Actions
              • Custom script: call RemoveLocation (udg_Points[2])
          • Custom script: call RemoveLocation (udg_Points[1])
For the threat system, you would need to explain it even more, but you seem like you want to do it, so my job is done ;)

If you are going to use Custom values for Asteroid Miners in other situations, I'd advise Hashtables, because the values will overwrite each other and the results will be unpredictable. If you want, I will show you a way to do so.

Edit: Oh, DarkAngelAzazel, it's just experience, you'll get better too :)
 
Level 5
Joined
May 27, 2007
Messages
162
Pharaoh knows a lot of ways to skin a cat :).

Threat system, like, another human player bringing his attacking force to where you are mining asteroids? :p, another idea is a Radar Ship that works like the Terran Radar Outpost in SC2 - pings the minimap location of enemy units nearby, in explored or unexplored terrain... Anyways, I'm going to make a map development thread for this!
 
Status
Not open for further replies.
Top