So I have a trigger which basically makes the triggering unit to attack move in a circle pattern to patrol.
it looks like this:
Events
Local Variables
Conditions
Actions
General - Repeat (Actions) forever
Actions
Unit - Order (Triggering unit) to ( Attack targeting Inner Patrol 001) (After Existing Orders)
Unit - Order (Triggering unit) to ( Attack targeting Inner Patrol 002) (After Existing Orders)
Unit - Order (Triggering unit) to ( Attack targeting Inner Patrol 003) (After Existing Orders)
Unit - Order (Triggering unit) to ( Attack targeting Inner Patrol 004) (After Existing Orders)
Unit - Order (Triggering unit) to ( Attack targeting Inner Patrol 005) (After Existing Orders)
Unit - Order (Triggering unit) to ( Attack targeting Inner Patrol 006) (After Existing Orders)
Unit - Order (Triggering unit) to ( Attack targeting Inner Patrol 007) (After Existing Orders)
General - Wait 120.0 Game Time seconds
Now, to clarify. It doesn't have an Event, because this Trigger is triggered by another Trigger. I have other Triggers that do the same thing as this Trigger does, but they don't give me the Error: Stack Overflow
When this error occurs, this Trigger doesn't even activate.
Could anyone explain why I'm getting this error? Also, if there is a more efficient method of having units patrol in a loop, please share.
First of all this code is a mess. You can barely read it.
Please format it so people don't have to spend 5 minutes just to decipher it. It'd be even better if you put it in CODE tags (you can see the tags just above the edit box where you write your message in).
Now to your problem:
You said this trigger is called by another trigger and that this trigger won't even activate when the error occurs.
So it's probable that it's not this trigger that causes an error, but in fact the calling trigger.
I'm not sure when you usually get a stack overflow, but no matter the cause, it'll probably be of some faulty usage of some action. If we can find the culprit the problem should go away.
A stack overflow almost always indicates infinite recursion. Like s3rius said the code you posted is unreadable and I'm not going to bother deciphering it but at some point in there you have an infinite loop where two functions are calling each other.
Ah, sorry about that, Copy and Pasted and didn't realize how badly that looked. Fixed it up so it should be easier to read.
Also, this is a forever repeating recursion, as the units will continuously attack move in the loop I specified in the trigger until they die. Is there a better way to do that?
The only problem I see in here is the use of (Triggering Unit).
(triggering unit) refers to a unit that activated the trigger. However you don't have an event, so there is no unit that activated it. You either need a global variable to pass the unit to this action, or you create a custom function instead of using this trigger.
I'm not sure whether this is cause of the Stack overflow, but it could be.
Hmmmm... The problem with this though, is that I already have Triggers just like this one, and they all seem to be working fine. I haven't had problems with (Triggering Units) using my other triggers.
Here is the Trigger that Activates the patrol trigger.
Send Hellions on Alt Patrol
Events
Unit - Any Unit Enters Hellion Spawn
Local Variables
Conditions
(Unit type of (Triggering unit)) == AI Hellion
And
Conditions
Send Hellions on Patrol == 1
Actions
Unit Group - Add (Triggering unit) to Alt Patrol (Hellions)
Unit - Order (Triggering unit) to ( Attack targeting Inner Patrol 020) (After Existing Orders)
Unit - Order (Triggering unit) to ( Attack targeting Inner Patrol 021) (After Existing Orders)
Trigger - Run Send Hellions on Alt Patrol (Check Conditions, Don't Wait until it finishes)
-----
To explain, When any unit enters the region "Hellion Spawn," and they are a Hellion, and the Variable "Send Hellions on Patrol" == 1, this trigger will send the hellions on a path to the patrol location where this trigger will activate the Patrol trigger which sends the Hellions on a patrol loop.
The variable is there because I have it so that the variable alternates between 1 and 0, depending on the value of the variable, another trigger sends the Hellions on a different patrol route.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
So I have a trigger which basically makes the triggering unit to attack move in a circle pattern to patrol.
it looks like this:
Events
Local Variables
Conditions
Actions
Actions
Now, to clarify. It doesn't have an Event, because this Trigger is triggered by another Trigger. I have other Triggers that do the same thing as this Trigger does, but they don't give me the Error: Stack Overflow
When this error occurs, this Trigger doesn't even activate.
Could anyone explain why I'm getting this error? Also, if there is a more efficient method of having units patrol in a loop, please share.
First of all this code is a mess. You can barely read it.
Please format it so people don't have to spend 5 minutes just to decipher it. It'd be even better if you put it in CODE tags (you can see the tags just above the edit box where you write your message in).
Now to your problem:
You said this trigger is called by another trigger and that this trigger won't even activate when the error occurs.
So it's probable that it's not this trigger that causes an error, but in fact the calling trigger.
I'm not sure when you usually get a stack overflow, but no matter the cause, it'll probably be of some faulty usage of some action. If we can find the culprit the problem should go away.
A stack overflow almost always indicates infinite recursion. Like s3rius said the code you posted is unreadable and I'm not going to bother deciphering it but at some point in there you have an infinite loop where two functions are calling each other.
Ah, sorry about that, Copy and Pasted and didn't realize how badly that looked. Fixed it up so it should be easier to read.
Also, this is a forever repeating recursion, as the units will continuously attack move in the loop I specified in the trigger until they die. Is there a better way to do that?
The only problem I see in here is the use of (Triggering Unit).
(triggering unit) refers to a unit that activated the trigger. However you don't have an event, so there is no unit that activated it. You either need a global variable to pass the unit to this action, or you create a custom function instead of using this trigger.
I'm not sure whether this is cause of the Stack overflow, but it could be.
Hmmmm... The problem with this though, is that I already have Triggers just like this one, and they all seem to be working fine. I haven't had problems with (Triggering Units) using my other triggers.
Here is the Trigger that Activates the patrol trigger.
Send Hellions on Alt Patrol
Events
Local Variables
Conditions
Actions
-----To explain, When any unit enters the region "Hellion Spawn," and they are a Hellion, and the Variable "Send Hellions on Patrol" == 1, this trigger will send the hellions on a path to the patrol location where this trigger will activate the Patrol trigger which sends the Hellions on a patrol loop.
The variable is there because I have it so that the variable alternates between 1 and 0, depending on the value of the variable, another trigger sends the Hellions on a different patrol route.