Staredit Network > Forums > SC1 UMS Mapmaking Assistance > Topic: Triggers causing lag
Triggers causing lag
May 17 2009, 9:19 pm
By: xhans2x  

May 17 2009, 9:19 pm xhans2x Post #1



I've played a few maps without hyper triggers that lag every 2 seconds or so (when the map checks the triggers). The main map I'm talking about is Diplomacy: Blood and Iron and a few other diplo maps. What exactly causes this slight lag? Is it the amount of triggers in the map? I'm asking this because I'm halfway done with my own diplo map with hyper triggers and by the time it's done it will have upwards of 6000-7000 triggers at least whereas the other maps I'm referring to all have around 2000.



None.

May 17 2009, 9:40 pm JaFF Post #2



I'm assuming that in the diplomacy map you've mentioned some system runs every trigger cycle.

You must understand that some actions cause much more lag than others. The laggiest actions are giving, creating, moving (perhaps, not sure about this one) and killing units. If the diplo map, say, scans through all the buildings on the map or something (scan = give orders), it is not unusual if it lags every time it does it.



None.

May 17 2009, 9:49 pm xhans2x Post #3



The map I'm talking about that lags gives resources every second based on how many buildings you have. So are you saying that it only lags when the trigger actually activates? Because in my map there will be about 3000-4000 triggers that involve killing/creating units and giving resources, but only about 150 will fire every 2 (based on a death counter) seconds and the rest will happen very rarely, or not at all.

Basically what I'm asking is if the lag created by the map checking the conditions of every trigger, or by the actions of the trigger?



None.

May 17 2009, 9:56 pm JaFF Post #4



For your case, you may safely assume that only actions cause lag.

If you're going to have 150 triggers run once every 2 seconds and find out that it lags too much, use the time deathcounter you have to 'spread' those 150 triggers across several trigger loops instead of doing it all in one.



None.

May 17 2009, 10:01 pm Vrael Post #5



It's possible to have very many triggers an no lag. The laggiest parts of starcraft are typically those in which starcraft is required to modify/move/create/kill units, probably because units are such a "large" part of the code, they have health, armor, attack, and their own graphics that must be drawn to the map. Map lag is not created by checking the conditions of the triggers, that's relatively easy for SC to do since it really just has to compare some data, it tends to be the actions of triggers that cause lag.



None.

May 17 2009, 10:32 pm xhans2x Post #6



Alright thanks guys. My map should be fine now. Just wanted to make sure before I finished it because doing 4000 more triggers only to have them cause massive lag would have been a nightmare.



None.

May 18 2009, 2:03 am xhans2x Post #7



Oh one more question. I'm up to above 5000 triggers now with about 2000 more to go. The map size is fucking HUGE though. It's at 7.5MB. At this rate it'll be 12mb when its done. Is this normal for the amount of triggers I have? And if it is, will the sheer size of it cause any lag in game with a full house? Cuz I tested in single player and no lag so far.



None.

May 18 2009, 2:17 am Pyro682 Post #8



Do you have any sounds? Is it 256x256? Do any of the triggers run constantly??? These things can help to increase filesize/create some delay in the map.



None.

May 18 2009, 2:36 am xhans2x Post #9



No sounds, its 256x256, and I'm not sure what you mean about the last part. 99% of them have preserve trigger in them, but the conditions are VERY specific so 99% aren't running at the same time. I just added about 800 triggers making the total around 6000. I noticed that the filesize jumped from 7.5mb to 9.7mb. The 800 triggers are all duplicates with 2 different variables, but the thing is they are short triggers. Here is what they look like:
Conditions:
Bring(p12,atleast,1,(x unit),(x location));
Bring(currentplayer,atleast,1,gateway,(x location);
Deaths(p8, exactly, 17, rhynadon);
Kill(currentplayer,atleast,1,hive);
Kill(currentplayer,atmost,0,lair);
Actions:
SetResources(currentplayer, add, oreandgas, (x amount));
PreserveTrigger();

Now I bet on a blank map adding 800 variations of this trigger would NOT raise the filesize by 2.2mb by itself. I've seen other maps with around 1000 triggers that are way less than 2.2mb.



None.

May 18 2009, 2:40 am xhans2x Post #10



Oh yeah I'm also using MindArchons trigger duplicator to make most of the trigs.



None.

May 18 2009, 4:06 am rockz Post #11

ᴄʜᴇᴇsᴇ ɪᴛ!

open up the map in winmpq, see what's so big. Each trigger is 2400 bytes, I think, but that's before compression. Empty triggers are compressed to be smaller than filled ones due to all the 0s. At 6000 triggers, that's 14 MB uncompressed.

Run a map compressor to see what you are looking at for a final map size. It sounds like you're running into problems with something crazy.



"Parliamentary inquiry, Mr. Chairman - do we have to call the Gentleman a gentleman if he's not one?"

May 18 2009, 5:03 am Pyro682 Post #12



I hear that Farty1Billion's TinyMap is the best one so far.

Do a User Search on SEN, then Go to his website. DL the program and run it. (make sure you have an extra copy of the map before you try to compress it, if anything messes up.)



None.

May 18 2009, 5:09 am Kaias Post #13



Quote from Vrael
...Map lag is not created by checking the conditions of the triggers...
I wish that were true.



None.

May 18 2009, 6:57 am xhans2x Post #14



I used a map compresser and got it down from 17mb to 560kb somehow. It doesn't matter though because whoever said that conditions don't cause lag lied. I have about 7500 triggers (only about 100 ever firing at one time now, and most of those are just adding resources) and with 6 people 1 second game time was equivalent to 5 seconds real time. The lag got a little bit better when people left, but the map is still unplayable with anything but 2 players, which defeats the purpose of a diplomacy game. I could remove the hyper triggers and have super lag every 2 seconds instead of every .1 second or remove all my innovations and make a regular boring diplo now.



None.

May 18 2009, 7:09 am xhans2x Post #15



Basically my income system was setup so that each city gave you income every second. The income level of the city was dependent upon 3 things. 1st is whether it's a national city filled with people of your nations population (either is or isn't, so it can be 2 states), 2nd is the level of development you invested in it (scale from 1-10, so 10 different states), 3rd was your tech level (1-5, 5 total). There were 70 cities on the map, so to account for every variation for a city it comes out to 2x10x5=100. 100x70 = 7000 total. Throw in about 500 other triggers and it capped out at around 7500.

Really don't want to remove all the multipliers and just make every city give the same set income like all other diplos.



None.

May 19 2009, 3:32 am Falkoner Post #16



Quote
I used a map compresser and got it down from 17mb to 560kb somehow

Nice, they're always good at compressing lots of triggers :)

If you get heavy lag, you can always slow the hypertriggers, rather than remove them, by making the waits longer, of course, this would mess up any Death Count Timers you're currently using :ermm: If you decrease the rate that the triggers are checked, it creates a LOT less lag, try it out.



None.

May 20 2009, 8:01 am xhans2x Post #17



Well I removed one of the multipliers and with the rest of the triggers added in the final amount of triggers for the finished map is under 3500. Tolerable with 3-4 players, but it gets pretty bad with a fullhouse and lategame when theres a lot of units its unplayable.

I could get rid of another 700 or so triggers if I could find out a way to get the map to differentiate between a finished and unfinished building. Everytime a certain building is created in my map I have a trigger that kills the building and adds a development level to the city it was next to. I first tried centering map location on the building so that I could handle 10 levels of development with 10 triggers, but I quickly found out that the game likes to remove unfinished buildings before finished buildings which would let players exploit triggers pretty easily.

Also how do I increase the wait time for my hyper triggers?



None.

May 20 2009, 8:41 am Ahli Post #18

I do stuff and thingies... Try widening and reducing the number of small nooks and crannies to correct the problem.

Quote from xhans2x
Well I removed one of the multipliers and with the rest of the triggers added in the final amount of triggers for the finished map is under 3500. Tolerable with 3-4 players, but it gets pretty bad with a fullhouse and lategame when theres a lot of units its unplayable.

I could get rid of another 700 or so triggers if I could find out a way to get the map to differentiate between a finished and unfinished building. Everytime a certain building is created in my map I have a trigger that kills the building and adds a development level to the city it was next to. I first tried centering map location on the building so that I could handle 10 levels of development with 10 triggers, but I quickly found out that the game likes to remove unfinished buildings before finished buildings which would let players exploit triggers pretty easily.
The actions will effect unfinished buildings. In conditions unfinished buildings are ignored.

C: Current Player brings at least 1 'terran supply depot' to 'Anywhere'
A: preserve trigger; center 'location' on 'terran supply depot'

C: Current Player brings at least 1 'terran supply depot' to 'location'
A: do the rest of your actions

// No more unfinished buildings will be removed (system waits untill the most left supply depot has been built)

Quote from xhans2x
Also how do I increase the wait time for my hyper triggers?
Use greater values like 200ms instead of 0?

btw, constantly running scripts are very laggy, too.




May 20 2009, 3:20 pm JaFF Post #19



xhans2x, I was the one who said that you can assume that conditions do not cause lag. I thought that for your case, it would be a safe assumption, but I guess I was wrong.

To reduce the lag, use the conditions that have the highest probability of being false first in the condition lists of triggers. That way, SC will check the minimal number of conditions.

Also, please describe in more detail how are you calculation the money given. I'm assuming that you're just using all possible outcomes of your three (now two) variables on every city, which is why you wrote 2*5*10*70=7000. If that is indeed the case, then answer this question:

Does the amount of money given a function dependent on those 3 or 2 variables? Or is it relatively close to some founction? Using binary countoffs might greatly simplify your triggers. Say the variables are x, y, z and M is the money you get. Then M = (10*x - y)/(z - 5*x) or whatever. Then it is just a matter of using one trigger system to calculate anything you need just by knowing the three input variables.



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[01:19 pm]
Vrael -- IM GONNA MANUFACTURE SOME SPORTBALL EQUIPMENT WHERE THE SUN DONT SHINE BOY
[01:35 am]
Ultraviolet -- Vrael
Vrael shouted: NEED SOME SPORTBALL> WE GOT YOUR SPORTBALL EQUIPMENT MANUFACTURING
Gonna put deez sportballs in your mouth
[2024-5-01. : 1:24 pm]
Vrael -- NEED SOME SPORTBALL> WE GOT YOUR SPORTBALL EQUIPMENT MANUFACTURING
[2024-4-30. : 5:08 pm]
Oh_Man -- https://youtu.be/lGxUOgfmUCQ
[2024-4-30. : 7:43 am]
NudeRaider -- Vrael
Vrael shouted: if you're gonna link that shit at least link some quality shit: https://www.youtube.com/watch?v=uUV3KvnvT-w
Yeah I'm not a big fan of Westernhagen either, Fanta vier much better! But they didn't drop the lyrics that fit the situation. Farty: Ich bin wieder hier; nobody: in meinem Revier; Me: war nie wirklich weg
[2024-4-29. : 6:36 pm]
RIVE -- Nah, I'm still on Orange Box.
[2024-4-29. : 4:36 pm]
Oh_Man -- anyone play Outside the Box yet? it was a fun time
[2024-4-29. : 12:52 pm]
Vrael -- if you're gonna link that shit at least link some quality shit: https://www.youtube.com/watch?v=uUV3KvnvT-w
[2024-4-29. : 11:17 am]
Zycorax -- :wob:
[2024-4-27. : 9:38 pm]
NudeRaider -- Ultraviolet
Ultraviolet shouted: NudeRaider sing it brother
trust me, you don't wanna hear that. I defer that to the pros.
Please log in to shout.


Members Online: Roy