# Storing points problem

Status
Not open for further replies.

#### streetpunk

Level 11
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.

#### Hotwer

Level 7
Have you tried using adding and removing events?

#### streetpunk

Level 11
You mean something like "unit enter/leaves region" ?

#### Hotwer

Level 7
Yes, but you can add events using triggers as well.

#### Kaijyuu

Level 11
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
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.

Replies
3
Views
652
Replies
8
Views
1K
Replies
0
Views
688
[Crash] Strange crash
Replies
8
Views
928
Replies
4
Views
491