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

Set trigger that sets rally point to nearest region.

Status
Not open for further replies.
Level 3
Joined
May 24, 2008
Messages
27
Thought I'd repost becuase of the lack of answer in the innapropriate place.

This is still unresolved, look here
w1.png


w2.png


The green squares in this next pic are the regions. I want the rally points to automaticly become set to its buildings nearest green square region
as soon as the building's built.
w3.png
 
Last edited by a moderator:
Level 9
Joined
Dec 6, 2007
Messages
233
Hmm, you could scan all of the regions for distance, then find the closest one. I just made a system like this for laser beam prediction, let me write a version for you.

EDIT: this should do it justice, tell me if you need anymore clarification

  • Closest Region Rally Set
    • Events
      • Unit - A unit Finishes construction
    • Conditions
    • Actions
      • Set Temp_Real = 9001.00
      • Set Temp_Loc = (Position of (Constructed structure))
      • -------- from 1 to (number of regions) --------
      • For each (Integer A) from 1 to 2, do (Actions)
        • Loop - Actions
          • -------- Region[#] is a region array, set each region to a different value of the array in another trigger --------
          • Set Temp_Loc2 = (Center of Region[(Integer A)])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between Temp_Loc and Temp_Loc2) Less than Temp_Real
            • Then - Actions
              • Custom script: call RemoveLocation(udg_Closest_Point)
              • Set Temp_Real = (Distance between Temp_Loc and Temp_Loc2)
              • Set Closest_Point = (Center of Region[(Integer A)])
            • Else - Actions
      • Unit - Order (Constructed structure) to Set Rally Point To Closest_Point
      • Custom script: call RemoveLocation(udg_Temp_Loc)
      • Custom script: call RemoveLocation(udg_Temp_Loc2)
      • Custom script: call RemoveLocation(udg_Closest_Point)
don't have time to test it right now, but i have faith it will work. if you see this before i test it, try it anyways

EDIT2: tested, works flawlessly as expected. Here an example of how to set up Region[#] properly, because i feel i was unclear.

  • region set
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Region[1] = Region 000 <gen>
      • Set Region[2] = Region 001 <gen>
 
Last edited:
Level 9
Joined
Dec 6, 2007
Messages
233
  • Closest Region Rally Set
    • Events
      • Unit - A unit Finishes construction
    • Conditions
    • Actions
      • Set Temp_Real = 9001.00
      • Set Temp_Loc = (Position of (Constructed structure))
      • For each (Integer A) from 1 to 2, do (Actions)
        • Loop - Actions
          • Set Temp_Loc2 = Region_Center[(Integer A)]
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between Temp_Loc and Temp_Loc2) Less than Temp_Real
            • Then - Actions
              • Custom script: call RemoveLocation(udg_Closest_Point)
              • Set Temp_Real = (Distance between Temp_Loc and Temp_Loc2)
              • Set Closest_Point = Region_Center[(Integer A)]
            • Else - Actions
          • Custom script: call RemoveLocation(udg_Temp_Loc2)
      • Unit - Order (Constructed structure) to Set Rally Point To Closest_Point
      • Custom script: call RemoveLocation(udg_Temp_Loc)
      • Custom script: call RemoveLocation(udg_Closest_Point)
This should be faster. But I did learn something new from DrSuperGood: if you want to make this EVEN faster, you can save the X and Y of the points instead of the whole location. I don't know the function right off the top of my head, but DrSuperGood could probably fill you in. Personally, I think this is plenty fast enough for your purposes. As stated, i have a *similar* system for drawing a laser beam to the closest object in front of it. It can scan 1050 points a second with zero lag; your system won't scan more than the number of regions you have, unless you complete a large number of buildings at once, and even then it won't get anywhere near the critical number to cause lag. Hope this helps
 
Status
Not open for further replies.
Top