Hello, I've been making this escape map where I have two periodic event triggers that make specific unit checks and then does some actions. I've set the periods to 0.01 seconds to be as smooth as possible, but it seems that after about 10 minutes or whatever into the game, triggers will stop funcitoning and I get the "too many threads" error spammed in my face.
Basically I have one trigger that checks if the ground height at a non-specific unit of the type Marine is less than or equal to X, and if it is, it will deal 5 damage to that unit.
The second trigger checks if a non-specific unit of the type Marine is within X range of a non-specific unit owned by player 15, and if it is, it will kill the Marine.
Are there any ways to replicate these functions with proper Event functions? I've tried "Unit Enters Range of Unit" for the second trigger, but it won't allow me to set the second Unit to a variable, but only allows specific units already placed on the map. I've tried a workaround like "Any unit Enters range of 1 of Closest Unit to Position of Triggering Unit", but it didn't seem to work, as the Triggering Unit part most likely does not work in an Event.
The problem is that the thing you are doing inside the actions of your periodic event cost too much time. Normally, even at 0.01second, this is not a problem. Unless you are using any sort of loops in there. Anything that can cost any realistic time (a wait loop for example) will stay alive until expired. At 0.01 this created 100 of these loops per second.
The longer these loops last, the more threads are created.
If its not too long, post your periodic event action list.
I'm still having problems with my map and too many threads. Only when I nuke 60 units in an instant though.
I've cut back on so much.
I think ti all comes down to the "unit dies" event for me now. It is too broad and gets used a lot in my map. Will have to test, investigate and look for more loops.
Thanks for the replies. These are the trigger actions:
----------------------
Trigger 1:
TempGroup = (Marine units in (Entire map) owned by player Any Player matching Excluded: Missile, Dead, Hidden, with at most Any Amount) <Unit Group>
Unit Group - Pick each unit in TempGroup and do (Actions)
- Actions
General - If (Conditions) then do (Actions) else do (Actions)
- If
(Ground height at (Position of (Picked unit))) <= Ground Height
- Then
Sound - Play Hellion_AttackImpact (Unnamed) for (All players) on (Picked unit) with Z offset 0.0 (at 100.0% volume, skip the first 0.0 seconds)
Unit - Set (Picked unit) Life to (((Picked unit) Life (Current)) - 5.0)
----------------------
Trigger 2:
TempGroup = (Marine units in (Entire map) owned by player Any Player matching Excluded: Missile, Dead, Hidden, with at most Any Amount) <Unit Group>
Unit Group - Pick each unit in TempGroup and do (Actions)
- Actions
General - If (Conditions) then do (Actions) else do (Actions)
- If
(Distance between (Position of (Picked unit)) and (Position of (Closest unit to (Position of (Picked unit)) in (Zergling No Attack (Burrowed) units in (Entire map) owned by player 15 matching No Unit Filter, with at most Any Amount)))) <= 0.65
- Then
Unit - Kill (Picked unit)
----------------------
How would I optimize this without losing the smoothness and accuracy of 0.01 seconds?
Could the problem be that my "Else" in the If Then Else is empty?
Isn't this going to spam the hell out of your speakers with a hellion attack impact? XD
If nothing else, combine your two loops. you're running two "pick each" units on the same unit group every 0.01 seconds, doubling your thread count. You can write both condition checks within the same 1 loop.
BUT ON TO MY SUGGESTION. heh.
I don't get why you need it to be 0.01 seconds. That's 10 milliseconds, players don't even have that sort of latency. But since you seem adament about it, here's a way I would think to optimize things. First create a loop trigger that has a longer timer a e.g. 200 milliseconds (0.2 seconds ) that checks for units matching the event, and once a unit is found, turn on another event to do the 0.01 periodic effect on the specified unit.
Maybe even considering doing an infinite loop until unit is dead, e.g.
periodic event every 0.2 seconds.
pick each marine, and check if they are in the height/etc. also check if they're not in a counter stack (an array that holds units)
if both pass true, run a custom action with parameter of unit.
action sets unit passed into the counter stack so it isn't ran twice on same unit. make a for (integer) loop that is like,
For Each integer X from 1 to 2 with increment 0, do (actions)
If marine is dead or the height is fixed,
then set integer x to 2
else deal teh damage/etc effects you want.
wait 0.01 seconds.
The 0.01 loop is only occurring when mob meets the criteria and starts a unique custom action to handle the effects you want for the duration of it's stay in the lava/etc, it'll shut itself off the moment that unit stops meeting the status. This is less stress when units aren't meeting the criteria, and when a unit dies it'll lower the threads needed to handle each unit (since the loop only occurs 0.2 seconds instead of 0.01.
In closing, this'll give the same "smoothness" of the illusion of a marine dying etc as you want, but lower the threads significantly to handle all the unit's on screen.
The only caveat is that when a unit first enters the lava it'll take 0.2 seconds for the event to start occurring, but once it starts it'll be as smooth as you always had it.
And you can tweak the 0.2 seconds anyways to a lower amount if you find the threads are handling this well.
Hello, I've been making this escape map where I have two periodic event triggers that make specific unit checks and then does some actions. I've set the periods to 0.01 seconds to be as smooth as possible, but it seems that after about 10 minutes or whatever into the game, triggers will stop funcitoning and I get the "too many threads" error spammed in my face.
Basically I have one trigger that checks if the ground height at a non-specific unit of the type Marine is less than or equal to X, and if it is, it will deal 5 damage to that unit. The second trigger checks if a non-specific unit of the type Marine is within X range of a non-specific unit owned by player 15, and if it is, it will kill the Marine.
Are there any ways to replicate these functions with proper Event functions? I've tried "Unit Enters Range of Unit" for the second trigger, but it won't allow me to set the second Unit to a variable, but only allows specific units already placed on the map. I've tried a workaround like "Any unit Enters range of 1 of Closest Unit to Position of Triggering Unit", but it didn't seem to work, as the Triggering Unit part most likely does not work in an Event.
Help me ;(
Red
Make it 0.3 at bare minimum.
Are you using any while loops or wait functions?
The problem is that the thing you are doing inside the actions of your periodic event cost too much time. Normally, even at 0.01second, this is not a problem. Unless you are using any sort of loops in there. Anything that can cost any realistic time (a wait loop for example) will stay alive until expired. At 0.01 this created 100 of these loops per second. The longer these loops last, the more threads are created.
If its not too long, post your periodic event action list.
I'm still having problems with my map and too many threads. Only when I nuke 60 units in an instant though.
I've cut back on so much.
I think ti all comes down to the "unit dies" event for me now. It is too broad and gets used a lot in my map. Will have to test, investigate and look for more loops.
You dont need to cut back, only optimize
Thanks for the replies. These are the trigger actions:
----------------------Trigger 1:
TempGroup = (Marine units in (Entire map) owned by player Any Player matching Excluded: Missile, Dead, Hidden, with at most Any Amount) <Unit Group>
Unit Group - Pick each unit in TempGroup and do (Actions)
- Actions
General - If (Conditions) then do (Actions) else do (Actions)
- If
(Ground height at (Position of (Picked unit))) <= Ground Height
- Then
Sound - Play Hellion_AttackImpact (Unnamed) for (All players) on (Picked unit) with Z offset 0.0 (at 100.0% volume, skip the first 0.0 seconds)
Unit - Set (Picked unit) Life to (((Picked unit) Life (Current)) - 5.0)
---------------------- Trigger 2:TempGroup = (Marine units in (Entire map) owned by player Any Player matching Excluded: Missile, Dead, Hidden, with at most Any Amount) <Unit Group>
Unit Group - Pick each unit in TempGroup and do (Actions)
- Actions
General - If (Conditions) then do (Actions) else do (Actions)
- If
(Distance between (Position of (Picked unit)) and (Position of (Closest unit to (Position of (Picked unit)) in (Zergling No Attack (Burrowed) units in (Entire map) owned by player 15 matching No Unit Filter, with at most Any Amount)))) <= 0.65
- Then
Unit - Kill (Picked unit)
----------------------How would I optimize this without losing the smoothness and accuracy of 0.01 seconds? Could the problem be that my "Else" in the If Then Else is empty?
bump :<
Isn't this going to spam the hell out of your speakers with a hellion attack impact? XD
If nothing else, combine your two loops. you're running two "pick each" units on the same unit group every 0.01 seconds, doubling your thread count. You can write both condition checks within the same 1 loop.
BUT ON TO MY SUGGESTION. heh.
I don't get why you need it to be 0.01 seconds. That's 10 milliseconds, players don't even have that sort of latency. But since you seem adament about it, here's a way I would think to optimize things. First create a loop trigger that has a longer timer a e.g. 200 milliseconds (0.2 seconds ) that checks for units matching the event, and once a unit is found, turn on another event to do the 0.01 periodic effect on the specified unit.
Maybe even considering doing an infinite loop until unit is dead, e.g.
periodic event every 0.2 seconds.
pick each marine, and check if they are in the height/etc. also check if they're not in a counter stack (an array that holds units)
if both pass true, run a custom action with parameter of unit.
action sets unit passed into the counter stack so it isn't ran twice on same unit. make a for (integer) loop that is like,
For Each integer X from 1 to 2 with increment 0, do (actions)
If marine is dead or the height is fixed,
then set integer x to 2
else deal teh damage/etc effects you want.
wait 0.01 seconds.
The 0.01 loop is only occurring when mob meets the criteria and starts a unique custom action to handle the effects you want for the duration of it's stay in the lava/etc, it'll shut itself off the moment that unit stops meeting the status. This is less stress when units aren't meeting the criteria, and when a unit dies it'll lower the threads needed to handle each unit (since the loop only occurs 0.2 seconds instead of 0.01.
In closing, this'll give the same "smoothness" of the illusion of a marine dying etc as you want, but lower the threads significantly to handle all the unit's on screen.
The only caveat is that when a unit first enters the lava it'll take 0.2 seconds for the event to start occurring, but once it starts it'll be as smooth as you always had it.
And you can tweak the 0.2 seconds anyways to a lower amount if you find the threads are handling this well.
Thanks for your reply, I will give this a try. I did not mean to rhyme, but I do not give a dime. Oh that was so lame. I need to play another game.
wat