I have a group of units that are constantly spawning and move from one point to another. When these units die, they are instantly revived. What I want is for the revived unit to continue down the path I set for it after it is revived.
Event:
Unit Enters "Start"
Actions:
Issue order (triggering unit) move to point A (after existing commands)
Issue order (triggering unit) move to point B (after existing commands)
Issue order (triggering unit) move to point C (after existing commands)
Now lets say, for example that a unit dies between point A and point B
Event:
Unit Dies
Actions:
Revive (Triggering Unit)
At this point I would like the revived unit to continue to B then C.
Is this something I could accomplish without having to make lots of regions and check where the unit is at when it's revived then order it to move to closest point to continue?
Rollback Post to RevisionRollBack
The Team - TnTProductions
TnTProductions latest Project - Docking Bay 13
TnTProductions Epic RPG in the making - Psionics: Chaos Rising
Check out our website on wixx! http://bulletbutter.wix.com/tntproductions
Yes you could, but I don't understand why don't you just make the units invulnerable if they are just going to revive instantly anyway?
There is several ways you could do that, one example:
Have a trigger with the events:
Any Unit comes within 0.02 of point A
Any Unit comes within 0.02 of point B
Any Unit comes within 0.02 of point C
etc.
Conditions:
Unit is of type (the type that is following the route)
Actions:
Set custom value 0 of unit to ((custom value 0 of unit) + 1)
And in your "Unit Dies" trigger, have all the points in an array (or use "get point from name" if they are numbered points), and order the unit to move to the points starting with the array index of (custom value 0 of triggering unit) and ending with the max index of the array.
If you're looking for a way to store a unit's orders just prior to it's death (other than with a periodic) I'm not sure, but maybe you could try the "Unit takes Damage" event and see if it triggers before the actual unit death? If it did you could temporarily store the unit's current orders and then re-issue them upon the unit's revival.
I tried it the first way. I gave the unit a custom value and ordered the units to move based on their custom value. Now the problem is that when the unit revives, it starts attacking. I think I understand why its happening. I think it's because I have set their movement to "After Existing Orders". So when the unit enters Entire Top region, their first order is to attack back, since my move order is set to "after existing orders". But, if I change it to "replace existing orders", the units make a straight line to the end. I want them to reach the center of each location.
The Team - TnTProductions
TnTProductions latest Project - Docking Bay 13
TnTProductions Epic RPG in the making - Psionics: Chaos Rising
Check out our website on wixx! http://bulletbutter.wix.com/tntproductions
If you were to order your points sequentially by sweeping down the map, would your order sequence remain the same? If so, I would suggest storing the orders in an array and issuing them through that with a condition that the unit isn't further down the map's y axis than the point it's supposed to go to.
Made and uploaded a map demonstrating this concept. The start button will issue the order array to the marine. You'll see that every time you kill him with the DT, he'll keep on moving. The only issue with this is you can get him to path backwards if you put the DT in a way that will path him above the Y of the point, but I reckon you can use the concept in a way that avoids this. If it comes down to it, you can have the game calculate several paths distances and use some math to figure out where it is on an single-dimension (the overall path) whether it is 'below' or 'above' points to do the same thing I was talking about.
The Team - TnTProductions
TnTProductions latest Project - Docking Bay 13
TnTProductions Epic RPG in the making - Psionics: Chaos Rising
Check out our website on wixx! http://bulletbutter.wix.com/tntproductions
I'm assuming it's a tower-defense type map? Just be aware that if it's a map where players can alter pathing by putting stuff in the way, this code may be exploitable if they make it so the pathing of the unit goes above it's rally point.
Indeed it is. Anti-walling is going to be the last thing I tackle, I expect to have a hard time with that. Thanks for the heads up.
Rollback Post to RevisionRollBack
The Team - TnTProductions
TnTProductions latest Project - Docking Bay 13
TnTProductions Epic RPG in the making - Psionics: Chaos Rising
Check out our website on wixx! http://bulletbutter.wix.com/tntproductions
Alright, so I made a more robust method of doing this that won't bug out from running over the same point or being forced to path above a point, etc.
It uses an array of units and a two-dimensional array of booleans as well as the original point array and order array. There is also a Constant integer that is used to define the number of units spawned as well as the sizes of the two new arrays. If you wanted to have different wave sizes, you could just change this to a non-constant and just make the arrays large enough to be able to hold your largest wave size.
Units are spawned via a loop that keys off of the constant. Each pass spawns a unit, assigns it to the unit array using the loop counter as the index, then issues the initial orders to the unit.
There are 8 triggers that relate to the 8 waypoints I've placed. They're all pretty much identical in what they do. What they do is run a loop to determine which unit in the array the unit is and set an entry in the boolean array to true, using the loop counter and a specific # as the indexes. I would have done these 8 triggers as 1 using a loop, but there is no preset for Any Point, and I feel that using other events to get around this would be less efficient in terms of system resources. It's not like the triggers are very large, anyway.
When the units revive, a loop triggers that cycles as many times as the number of units in the wave. There is an if-then statement that checks to see if the triggering unit is a unit in the array, using the loop counter as the index. On a true, it runs another loop that cycles as many times as there are waypoint. There is an if-then statement in this loop that checks to see if an entry in the boolean array is false, using the first and second loop counters as index #s. If it is false, then it issues the unit order in the order array using the second loop counter as the index.
As for anti-walling, it's actually fairly straightforward. You create a new unit type (Pathing Tester) that is invisible within your unit spawn area and have it always stay there. Then you create a trigger that triggers when your builders build something with a comparison of the pathing cost of the Pathing Tester to your 'end' point. If it is -1 (what the game uses for infinity in this case) then remove building, refund cost, etc.
I have a group of units that are constantly spawning and move from one point to another. When these units die, they are instantly revived. What I want is for the revived unit to continue down the path I set for it after it is revived.
Event:
Actions:
Now lets say, for example that a unit dies between point A and point B
Event:
Actions:
Is this something I could accomplish without having to make lots of regions and check where the unit is at when it's revived then order it to move to closest point to continue?
@bulletbutter: Go
Yes you could, but I don't understand why don't you just make the units invulnerable if they are just going to revive instantly anyway?
There is several ways you could do that, one example:
Have a trigger with the events:
Conditions:
Actions:
And in your "Unit Dies" trigger, have all the points in an array (or use "get point from name" if they are numbered points), and order the unit to move to the points starting with the array index of (custom value 0 of triggering unit) and ending with the max index of the array.
@DeltaV: Go
If you're looking for a way to store a unit's orders just prior to it's death (other than with a periodic) I'm not sure, but maybe you could try the "Unit takes Damage" event and see if it triggers before the actual unit death? If it did you could temporarily store the unit's current orders and then re-issue them upon the unit's revival.
@DeltaV: Go
I tried it the first way. I gave the unit a custom value and ordered the units to move based on their custom value. Now the problem is that when the unit revives, it starts attacking. I think I understand why its happening. I think it's because I have set their movement to "After Existing Orders". So when the unit enters Entire Top region, their first order is to attack back, since my move order is set to "after existing orders". But, if I change it to "replace existing orders", the units make a straight line to the end. I want them to reach the center of each location.
I created 2 regions (entire top & entire bottom)
@bulletbutter: Go
If you were to order your points sequentially by sweeping down the map, would your order sequence remain the same? If so, I would suggest storing the orders in an array and issuing them through that with a condition that the unit isn't further down the map's y axis than the point it's supposed to go to.
Made and uploaded a map demonstrating this concept. The start button will issue the order array to the marine. You'll see that every time you kill him with the DT, he'll keep on moving. The only issue with this is you can get him to path backwards if you put the DT in a way that will path him above the Y of the point, but I reckon you can use the concept in a way that avoids this. If it comes down to it, you can have the game calculate several paths distances and use some math to figure out where it is on an single-dimension (the overall path) whether it is 'below' or 'above' points to do the same thing I was talking about.
@Tudentau: Go
Awesome, that helped soo much!
@bulletbutter: Go
I'm assuming it's a tower-defense type map? Just be aware that if it's a map where players can alter pathing by putting stuff in the way, this code may be exploitable if they make it so the pathing of the unit goes above it's rally point.
@Tudentau: Go
Indeed it is. Anti-walling is going to be the last thing I tackle, I expect to have a hard time with that. Thanks for the heads up.
@bulletbutter: Go
Alright, so I made a more robust method of doing this that won't bug out from running over the same point or being forced to path above a point, etc.
It uses an array of units and a two-dimensional array of booleans as well as the original point array and order array. There is also a Constant integer that is used to define the number of units spawned as well as the sizes of the two new arrays. If you wanted to have different wave sizes, you could just change this to a non-constant and just make the arrays large enough to be able to hold your largest wave size.
Units are spawned via a loop that keys off of the constant. Each pass spawns a unit, assigns it to the unit array using the loop counter as the index, then issues the initial orders to the unit.
There are 8 triggers that relate to the 8 waypoints I've placed. They're all pretty much identical in what they do. What they do is run a loop to determine which unit in the array the unit is and set an entry in the boolean array to true, using the loop counter and a specific # as the indexes. I would have done these 8 triggers as 1 using a loop, but there is no preset for Any Point, and I feel that using other events to get around this would be less efficient in terms of system resources. It's not like the triggers are very large, anyway.
When the units revive, a loop triggers that cycles as many times as the number of units in the wave. There is an if-then statement that checks to see if the triggering unit is a unit in the array, using the loop counter as the index. On a true, it runs another loop that cycles as many times as there are waypoint. There is an if-then statement in this loop that checks to see if an entry in the boolean array is false, using the first and second loop counters as index #s. If it is false, then it issues the unit order in the order array using the second loop counter as the index.
As for anti-walling, it's actually fairly straightforward. You create a new unit type (Pathing Tester) that is invisible within your unit spawn area and have it always stay there. Then you create a trigger that triggers when your builders build something with a comparison of the pathing cost of the Pathing Tester to your 'end' point. If it is -1 (what the game uses for infinity in this case) then remove building, refund cost, etc.