hi,
Often times Starcraft freezes for me, when I test my map. I think it is because of very long repeats. My new method is to split up a long function into parts and then get a trigger (periodic event) do everything step by step. That works quite often. But I have some functions that need to have ridiculous amounts of time in between them like 3 secs or so, usually 0.2 seconds does the trick.
Does anyone have some tips for me? Is there a better way to not let SC2 crash because of long functions? Other than smarter programming :)
Long durations on Periodic Events shouldn't have an impact on performance. They'll generally only bog things down if you use a lot of them in rapid succession - or have a lot of them firing at once.
Try creating your periodic actions inside While loops, using Repeat Forever with an appropriate Wait on the end for the delay between repeats. (Instead of the Periodic Event function)
It gives the same result, but with much less system lag. I've used it to clear up hiccuping performance several times.
thx. I will use this in the future. Thing is, the function I am having currently trouble with doesn't work with any attempt. :(
Can someone look into this?
I am making a minesweeper game. I am having trouble with one action called "searchfreefields". If you click on a point that has no mine near, all free fields will be revealed. This action works very well, but when it gets to a big grid with few mines, SC2 just freezes. You can recreate the problem by changing the grid size to max 30 * 30 and keep the minecount at 10. Then click on a field (try bottom, its worst). If it doesnt crash, just click on the smiley to reset the map and do it again.
The function in detail: You start with the point where you clicked. the tempSEARCH variables are every surrounding point. Now the function looks, if there is a field with number, or without. numberGRID: if 0, no mine around thus the action will save this position, to run the whole function from here. The position will be revealed. numberGrid if >0, the point will be revealed, but not saved.
I also check for flags (flagPOSITION) if there is a flag on a position, it will not be revealed, and if it has already been revealed (clearedGRID).
tempSEARCH > 0 ... means that it shall only check positions inside the grid (because outside the grid are no positions).
the directions on the grid map are: 1,1 is bottom left. x (1) direction is horizontal, and y (2) direction is vertical. It often stops in the about y = 27, so close to the simley.
I thought about changing the minimal possible mine amount, but I dont know if this will fully solve the problem.
I kinda solved this. My problems are. I have learned that you shouldn't create or kill many units at once, or else SC2 crashes. I now create the units at the start of the game and hide them, and when I need them I show them instead of creating them and Hide them instead of killing them, which is much faster. Also Sc2 crashes when you use "any" unit instead of "living" unit. Also it seems, if a function is too long and too performance intensive, it still remains hard to split it.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
hi, Often times Starcraft freezes for me, when I test my map. I think it is because of very long repeats. My new method is to split up a long function into parts and then get a trigger (periodic event) do everything step by step. That works quite often. But I have some functions that need to have ridiculous amounts of time in between them like 3 secs or so, usually 0.2 seconds does the trick.
Does anyone have some tips for me? Is there a better way to not let SC2 crash because of long functions? Other than smarter programming :)
@Ludwigvan1: Go
Long durations on Periodic Events shouldn't have an impact on performance. They'll generally only bog things down if you use a lot of them in rapid succession - or have a lot of them firing at once.
Try creating your periodic actions inside While loops, using Repeat Forever with an appropriate Wait on the end for the delay between repeats. (Instead of the Periodic Event function)
It gives the same result, but with much less system lag. I've used it to clear up hiccuping performance several times.
@Telthalion: Go
thx. I will use this in the future. Thing is, the function I am having currently trouble with doesn't work with any attempt. :(
Can someone look into this?
I am making a minesweeper game. I am having trouble with one action called "searchfreefields". If you click on a point that has no mine near, all free fields will be revealed. This action works very well, but when it gets to a big grid with few mines, SC2 just freezes. You can recreate the problem by changing the grid size to max 30 * 30 and keep the minecount at 10. Then click on a field (try bottom, its worst). If it doesnt crash, just click on the smiley to reset the map and do it again.
The function in detail: You start with the point where you clicked. the tempSEARCH variables are every surrounding point. Now the function looks, if there is a field with number, or without. numberGRID: if 0, no mine around thus the action will save this position, to run the whole function from here. The position will be revealed. numberGrid if >0, the point will be revealed, but not saved. I also check for flags (flagPOSITION) if there is a flag on a position, it will not be revealed, and if it has already been revealed (clearedGRID). tempSEARCH > 0 ... means that it shall only check positions inside the grid (because outside the grid are no positions). the directions on the grid map are: 1,1 is bottom left. x (1) direction is horizontal, and y (2) direction is vertical. It often stops in the about y = 27, so close to the simley.
I thought about changing the minimal possible mine amount, but I dont know if this will fully solve the problem.
I kinda solved this. My problems are. I have learned that you shouldn't create or kill many units at once, or else SC2 crashes. I now create the units at the start of the game and hide them, and when I need them I show them instead of creating them and Hide them instead of killing them, which is much faster. Also Sc2 crashes when you use "any" unit instead of "living" unit. Also it seems, if a function is too long and too performance intensive, it still remains hard to split it.