I am just playing around with triggers as I am quite new to them. Right now I am just experimenting with issuing orders to a unit to move to specific points on the map. Basically, the unit travels in a circle when I have the points setup and the actions set to move the unit. I have got that working pretty good and I am using a loop to make the unit travel to each point forever. Now I want to stop the unit at a specific point and have it wait there for a specified period of time before it continues moving to the next point. Basically, the unit right now is moving between 4 points and stops at point003. I would like it to wait there for 10 seconds before moving to point004. I have got the unit to stop but it only stays there for a second before continuing to the next point.I want the unit to stay at point003 for at least 10 seconds but havn't found a way to do this.
I have tried using a timer with a wait for timer trigger but either the unit doesn't stop for the amount of time I want or the unit stops and does not move again. Is there an easy way to do this. I found it quite easy to have the unit move to specific points and loop so it effectively runs in circles but I am having alot of trouble getting the unit to stop for a period of time before moving again.
Any help/suggestions on this would be greatly appreciated. Thanks in advance.
This is a very easy fix. Just use a "Wait" command as the first line in the trigger actions, before any issue order command. Search for the trigger action "Wait."
Hi Bilxor,Thanks for the reply! I just gave that a try and the movement triggers are delayed for the time I want but I want the delay to occur at a specific point. I tried adding the wait command after the unit stops but he just keeps going on his merry way =(
I could have the wait command at the start of my order commands and plan the sequence around that but it seems to only do it once during the loop. I want the unit to always stop at the same point, wait there, and continue on. The sequence is a loop so the unit always needs to stop at the same point and wait for the specified time (in this case, the unit stops at point003 and needs to wait 10 seconds then continue to point004).
If it helps, here is the code for the sequence I am tring to do (updated with the wait command):
The reason why your unit keeps moving is because it does this:
orders, make the game wait 10 seconds, more orders
Orders are given almost instantly, so the game automatically waits 10 seconds before adding more orders to the unit's queue. But it doesn't mean the unit is waiting 10 seconds, it just means the orders are given to the unit 10 seconds apart.
What you want is this:
orders, make the unit wait 10 seconds at a point, more orders
Right before the Wait, you should use a Wait for Condition. The condition you're looking for here is Distance between points, which allows you (among other things) to wait until a specific point (the position of your probe) is close enough to a specific position (point 003) before executing more actions.
Basically, you script will look like this:
Order to move (point 02)
Order to move (point 03)
Wait for condition: Distance between Position of Probe and Point 03 < 1
Order to stop (though ordering to hold position is probably better)
Wait 10 seconds
Order to move (point 04)
(etc etc...)
On a side note, if you want to make a unit really patrol an entire path (and attacking enemies on sight, if any), you just need to order it to patrol instead of just moving + repeating forever. It will move back and forth on the given path, and even patrol in circles if the last order is on the same spot as the first one.
Hi ZealNaga, thank you for the info. I am going to give this a try and I will report back my results. What you are saying makes sense so I think I can get this. Mainly, my objective is just to go through the paces and learn the process of controlling a units movement. Ultimately, this is leading to a much more complex project that I am working on. I have an urban city map that is in the early stages of development. The "showpiece" of the map will involve what I am learning here with this trigger sequence. I am working on a monorail that has its train move on a track throughout the city that I am making. At first, I was content with just having the train move around the track but then I realized for the sake of realism, the train should stop at certian points such as a simulated train station. I have the train running on the track quite well but then I hit a brick wall with controlling its movement. Now I can see there is a logical way of doing this. I can't wait to try it out!
Well, I have tried ZealNaga's suggestions and I have had some good results. I have got the unit to stop and move on point003 like I wanted. This is great. I have run into another issue however. Because this sequence is suppose to loop forever, I need this stop/go action to loop forever as well. I have found that the stop action only works once. After the unit travels around all the points and begins the actions again (ie moving to the same points as previous), the stop action seems to be ignored. I suspect it is because the wait for condition>distance between probe is no longer valid because the probe is in motion after the first loop so the position no longer applies. I tried a few different things and found that applying a repeat action to the wait for condition script allowed this action to repeat like I want but I have since changed the script and can't seem to get this to work anymore. I have no idea if that was the right approach but for awhile it seemed like I was on the right track, now I am not so sure...
Anyway, I am hoping there is some additional script that I can use to allow this stop/go sequence to intiate everytime the loop resets. As it stands, it seems like it will only trigger once and then is ignored for the rest of the loop.
If it is only possible to use this script once, I may have to revise my monorail idea so that it runs on one track and despawns and short while later comes back on a new track. I think I can make that work based on what I have learned so far.
Anyway, if anyone has any suggestions, I would really appreciate it!
The image below shows my existing script. The unit stops when it suppose to and starts moving to the next point when I want it to, but it will only do it once and then ignores the Wait for Condition action for the remainder of the loop.
Also, I am going to try using the patrol method suggested by ZealNaga. Perhaps I may have more luck with that. Thanks in advance for any suggetions/input.
PS> I noticed there is a red diamond on this trigger now. Does that mean there is an error wth the trigger? I didn't see that before so i am not sure if its indicating some kind of syntax error.
Let's deal with one problem at a time... First problem, the unit not stopping anymore after the first loop is done. I'm pretty sure this has to do with the fact that a unit's queue has a limit. Basically, your loop give orders faster than the unit can handle them. The Wait for Condition is not ignored, actually it's waiting for the condition forever. If you look at the Repeat loop closely, the last action is a "give order", and the first one is also a "give order"... which means when the loop is running, there is no wait between the last action and the first one, they are basically both ordered almost instantly to the probe. What you will need here is pretty much the same Wait for Condition used before, except you'll need to check the distance between your unit and point 01. It will allow orders to be given to the probe step by step, so that the unit's queue is never full. Ideally, use a Wait for Condition for each point in the track, this way you can make a track with as many points as you wish and it will run perfectly smooth.
About the little red diamond, yes, it's usually because there is a missing/undefined parameter somewhere. But it's also a very common bug happening when you undo something in the Triggers window (especially when using If/Then/Else, While loops, Switches, etc...). Just copy+paste the content of your trigger, either in a new trigger or where it has always been, the copy should be displayed normally again so you'll just have to remove the old one.
After the Probe waits 10 seconds it doesn't immediately leave point 3.
The Probe instantly queues up another round of move commands and immediately starts waiting on the next 10 seconds. By the time it finishes its commands, the 10 second wait is already done.
Here's a quick fix:
Add a "Wait N seconds" right before your "Wait for Conditions Checking every second" command.
N is the time it takes your Probe to leave the 1 radius circle around Point 3. (lets say 3 seconds?)
Add a "Wait N seconds" right before your "Wait for Conditions Checking every second" command.
N is the time it takes your Probe to leave the 1 radius circle around Point 3. (lets say 3 seconds?)
An even quicker fix would be to set the distance check to a value lower than 1 (ex: 0.1 or even 0.05). It prevents adding actions by dozens if you ever need to add more points in the path.
An even quicker fix would be to set the distance check to a value lower than 1 (ex: 0.1 or even 0.05). It prevents adding actions by dozens if you ever need to add more points in the path.
Doing that alone won't fix the problem. You'll still end up with the same behavior that uberOverlord described.
I'd just make a trigger for every stop you want the probe to make. So in this case, the trigger would fire when the Probe arrives at Point 3, at which point it would wait for 10 seconds, then issue the round of orders that would lead it back to Point 3 again. You'd just have to have a separate trigger to jump start the process to get the probe to Point 3 (unless the probe initially starts at that position).
This is great info, thanks for all the replies. I am going to give this a try. I will post my results when I have this working. 3 days ago, I was pretty clueless as to how to operate triggers but things are slowly making sense. I appreciate all the help!
Bingo! Ok, looks like I got this working now. The probe is now stopping where I want and continues on the path as it should. This is exactly what I want. The test file has been running for the last 19mins and is functioning properly. I added the wait for condition action as ZealNaga suggested and now the trigger is good to go. Also, the red diamond has disappeared. When I opened the file and when to the triggers, I got a invalid entry message in the log and the program reported that the entry was removed. So looks like it is good to go. Now I am ready to move onto the next stage of my project. I am really excited to have learned what I have learned here. It seems that even the average joe can do some really neat things with the editor with a little elbow grease and the right kind of help. Everyone here is awesome and I thank you all so much. Now I am off to conquer my city map! Cheers!
Below is a final screenshot of the end result.
ATTACHMENTS
final_trigger.jpg
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hello all,
I am just playing around with triggers as I am quite new to them. Right now I am just experimenting with issuing orders to a unit to move to specific points on the map. Basically, the unit travels in a circle when I have the points setup and the actions set to move the unit. I have got that working pretty good and I am using a loop to make the unit travel to each point forever. Now I want to stop the unit at a specific point and have it wait there for a specified period of time before it continues moving to the next point. Basically, the unit right now is moving between 4 points and stops at point003. I would like it to wait there for 10 seconds before moving to point004. I have got the unit to stop but it only stays there for a second before continuing to the next point.I want the unit to stay at point003 for at least 10 seconds but havn't found a way to do this.
I have tried using a timer with a wait for timer trigger but either the unit doesn't stop for the amount of time I want or the unit stops and does not move again. Is there an easy way to do this. I found it quite easy to have the unit move to specific points and loop so it effectively runs in circles but I am having alot of trouble getting the unit to stop for a period of time before moving again.
Any help/suggestions on this would be greatly appreciated. Thanks in advance.
This is a very easy fix. Just use a "Wait" command as the first line in the trigger actions, before any issue order command. Search for the trigger action "Wait."
<Click Here> To See My Epic Single Player Campaign (LifeForceCampaign.com)
@Bilxor: Go
Hi Bilxor,Thanks for the reply! I just gave that a try and the movement triggers are delayed for the time I want but I want the delay to occur at a specific point. I tried adding the wait command after the unit stops but he just keeps going on his merry way =(
I could have the wait command at the start of my order commands and plan the sequence around that but it seems to only do it once during the loop. I want the unit to always stop at the same point, wait there, and continue on. The sequence is a loop so the unit always needs to stop at the same point and wait for the specified time (in this case, the unit stops at point003 and needs to wait 10 seconds then continue to point004).
If it helps, here is the code for the sequence I am tring to do (updated with the wait command):
--------------------Trigger: unit_move_test-------------------- bool gt_unit_move_test_Func (bool testConds, bool runActions) {Actions if (!runActions) { return true; }while (true) {
UnitIssueOrder(UnitFromId(5), OrderTargetingPoint(AbilityCommand("move", 0), PointFromId(2)), c_orderQueueAddToEnd);
UnitIssueOrder(UnitFromId(5), OrderTargetingPoint(AbilityCommand("move", 0), PointFromId(3)), c_orderQueueAddToEnd);
UnitIssueOrder(UnitFromId(5), Order(AbilityCommand("stop", 0)), c_orderQueueAddToEnd); Wait(10.0, c_timeGame);
UnitIssueOrder(UnitFromId(5), OrderTargetingPoint(AbilityCommand("move", 0), PointFromId(4)), c_orderQueueAddToEnd);
UnitIssueOrder(UnitFromId(5), OrderTargetingPoint(AbilityCommand("move", 0), PointFromId(1)), c_orderQueueAddToEnd);
Wait(0.5, c_timeGame); } return true; }
The reason why your unit keeps moving is because it does this:
orders, make the game wait 10 seconds, more orders
Orders are given almost instantly, so the game automatically waits 10 seconds before adding more orders to the unit's queue. But it doesn't mean the unit is waiting 10 seconds, it just means the orders are given to the unit 10 seconds apart.
What you want is this:
orders, make the unit wait 10 seconds at a point, more orders
Right before the Wait, you should use a Wait for Condition. The condition you're looking for here is Distance between points, which allows you (among other things) to wait until a specific point (the position of your probe) is close enough to a specific position (point 003) before executing more actions.
Basically, you script will look like this:
Order to move (point 02)
Order to move (point 03)
Wait for condition: Distance between Position of Probe and Point 03 < 1
Order to stop (though ordering to hold position is probably better)
Wait 10 seconds
Order to move (point 04)
(etc etc...)
On a side note, if you want to make a unit really patrol an entire path (and attacking enemies on sight, if any), you just need to order it to patrol instead of just moving + repeating forever. It will move back and forth on the given path, and even patrol in circles if the last order is on the same spot as the first one.
@ZealNaga: Go
Hi ZealNaga, thank you for the info. I am going to give this a try and I will report back my results. What you are saying makes sense so I think I can get this. Mainly, my objective is just to go through the paces and learn the process of controlling a units movement. Ultimately, this is leading to a much more complex project that I am working on. I have an urban city map that is in the early stages of development. The "showpiece" of the map will involve what I am learning here with this trigger sequence. I am working on a monorail that has its train move on a track throughout the city that I am making. At first, I was content with just having the train move around the track but then I realized for the sake of realism, the train should stop at certian points such as a simulated train station. I have the train running on the track quite well but then I hit a brick wall with controlling its movement. Now I can see there is a logical way of doing this. I can't wait to try it out!
Thanks so much for the advice, much appreciated!
Hi again,
Well, I have tried ZealNaga's suggestions and I have had some good results. I have got the unit to stop and move on point003 like I wanted. This is great. I have run into another issue however. Because this sequence is suppose to loop forever, I need this stop/go action to loop forever as well. I have found that the stop action only works once. After the unit travels around all the points and begins the actions again (ie moving to the same points as previous), the stop action seems to be ignored. I suspect it is because the wait for condition>distance between probe is no longer valid because the probe is in motion after the first loop so the position no longer applies. I tried a few different things and found that applying a repeat action to the wait for condition script allowed this action to repeat like I want but I have since changed the script and can't seem to get this to work anymore. I have no idea if that was the right approach but for awhile it seemed like I was on the right track, now I am not so sure...
Anyway, I am hoping there is some additional script that I can use to allow this stop/go sequence to intiate everytime the loop resets. As it stands, it seems like it will only trigger once and then is ignored for the rest of the loop.
If it is only possible to use this script once, I may have to revise my monorail idea so that it runs on one track and despawns and short while later comes back on a new track. I think I can make that work based on what I have learned so far.
Anyway, if anyone has any suggestions, I would really appreciate it!
The image below shows my existing script. The unit stops when it suppose to and starts moving to the next point when I want it to, but it will only do it once and then ignores the Wait for Condition action for the remainder of the loop.
Also, I am going to try using the patrol method suggested by ZealNaga. Perhaps I may have more luck with that. Thanks in advance for any suggetions/input.
PS> I noticed there is a red diamond on this trigger now. Does that mean there is an error wth the trigger? I didn't see that before so i am not sure if its indicating some kind of syntax error.
Let's deal with one problem at a time... First problem, the unit not stopping anymore after the first loop is done. I'm pretty sure this has to do with the fact that a unit's queue has a limit. Basically, your loop give orders faster than the unit can handle them. The Wait for Condition is not ignored, actually it's waiting for the condition forever. If you look at the Repeat loop closely, the last action is a "give order", and the first one is also a "give order"... which means when the loop is running, there is no wait between the last action and the first one, they are basically both ordered almost instantly to the probe. What you will need here is pretty much the same Wait for Condition used before, except you'll need to check the distance between your unit and point 01. It will allow orders to be given to the probe step by step, so that the unit's queue is never full. Ideally, use a Wait for Condition for each point in the track, this way you can make a track with as many points as you wish and it will run perfectly smooth.
About the little red diamond, yes, it's usually because there is a missing/undefined parameter somewhere. But it's also a very common bug happening when you undo something in the Triggers window (especially when using If/Then/Else, While loops, Switches, etc...). Just copy+paste the content of your trigger, either in a new trigger or where it has always been, the copy should be displayed normally again so you'll just have to remove the old one.
After the Probe waits 10 seconds it doesn't immediately leave point 3.
The Probe instantly queues up another round of move commands and immediately starts waiting on the next 10 seconds. By the time it finishes its commands, the 10 second wait is already done.
Here's a quick fix:
Add a "Wait N seconds" right before your "Wait for Conditions Checking every second" command.
N is the time it takes your Probe to leave the 1 radius circle around Point 3. (lets say 3 seconds?)
An even quicker fix would be to set the distance check to a value lower than 1 (ex: 0.1 or even 0.05). It prevents adding actions by dozens if you ever need to add more points in the path.
Doing that alone won't fix the problem. You'll still end up with the same behavior that uberOverlord described.
I'd just make a trigger for every stop you want the probe to make. So in this case, the trigger would fire when the Probe arrives at Point 3, at which point it would wait for 10 seconds, then issue the round of orders that would lead it back to Point 3 again. You'd just have to have a separate trigger to jump start the process to get the probe to Point 3 (unless the probe initially starts at that position).
This is great info, thanks for all the replies. I am going to give this a try. I will post my results when I have this working. 3 days ago, I was pretty clueless as to how to operate triggers but things are slowly making sense. I appreciate all the help!
@SCmapnoob: Go
Bingo! Ok, looks like I got this working now. The probe is now stopping where I want and continues on the path as it should. This is exactly what I want. The test file has been running for the last 19mins and is functioning properly. I added the wait for condition action as ZealNaga suggested and now the trigger is good to go. Also, the red diamond has disappeared. When I opened the file and when to the triggers, I got a invalid entry message in the log and the program reported that the entry was removed. So looks like it is good to go. Now I am ready to move onto the next stage of my project. I am really excited to have learned what I have learned here. It seems that even the average joe can do some really neat things with the editor with a little elbow grease and the right kind of help. Everyone here is awesome and I thank you all so much. Now I am off to conquer my city map! Cheers!
Below is a final screenshot of the end result.