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

Storing points problem

Status
Not open for further replies.
Level 11
Joined
Oct 9, 2015
Messages
721
So I was in need of help doing something point-related. My goal is to store 2 or more points when unit is ordered to patrol: The position of the unit and the position of the issued order. So I stored them in variables, something like this:

  • FACSYS Order Memory
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
    • Actions
      • Set FACSYS_TempOrder = (Issued order)
      • Set FACSYS_Unit[1] = (Triggering unit)
      • Set FACSYS_TempInteger[1] = (Custom value of FACSYS_Unit[1])
      • -------- Here we check for Patrol order --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • FACSYS_TempOrder Equal to FACSYS_OrderPatrol
        • Then - Actions
          • Set FACSYS_StoredOrder[FACSYS_TempInteger[1]] = FACSYS_TempOrder
          • Set FACSYS_Loc[FACSYS_TempInteger[1]] = (Position of FACSYS_Unit[1])
          • Set FACSYS_Loc1[FACSYS_TempInteger[1]] = (Target point of issued order)
        • Else - Actions
Then what I need is to check periodicaly if the "Stored Order" is patrol, if so then order the unit from it's current position to go and patrol between the 2 stored points, but the current position of the unit isn't the same position stored before, it's a new one, so I check to see which of the two points are closer the the unit's location:
  • Untitled Trigger 003
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • FACSYS_StoredOrder[FACSYS_TempInteger[1]] Equal to FACSYS_OrderPatrol
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between FACSYS_Loc[1] and FACSYS_Loc[FACSYS_TempInteger[1]]) Greater than (Distance between FACSYS_Loc[1] and FACSYS_Loc1[FACSYS_TempInteger[1]])
            • Then - Actions
              • Unit - Order FACSYS_Unit[1] to Patrol To FACSYS_Loc[FACSYS_TempInteger[1]]
            • Else - Actions
              • Unit - Order FACSYS_Unit[1] to Patrol To FACSYS_Loc1[FACSYS_TempInteger[1]]
        • Else - Actions
So we have the unit on a different location than the original one ordered to patrol to the closer of the two stored points. But when the unit gets to the ordered point I need it to be ordered to patrol to the second points. I was in need of help acomplishing that, if anyone can shed a light here that would be great.

PS: I also needed to store more than two points as patrol orders can be queued.
 
Level 11
Joined
Jun 2, 2004
Messages
849
You can dynamically create regions to use in your dynamically created events too, for extra fun.

Plop down two small regions at the start and end and add Unit Enters Region events that check if this unit is the entering unit. Should be expandable for queued patrols, too.

Of course, clean up the regions when you're done with them too, else you'll get quite nasty leaks.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
For patrol routes you want a waypoint system. Until the unit enters a waypoint region, it will periodically be ordered to the middle of the waypoint region area if idle. When it enters the waypoint region it then updates to go to another waypoint region, the next patrol position. This is highly scaleable as polling the current order every second or so is trivial.

If pulled too far from the waypoint such that it is closer to another waypoint then it will unfortunately have to walk back. However this should seldom be a problem.
 
Status
Not open for further replies.
Top