| 08-08-2003, 05:05 PM | #1 |
Hello, I'm working on an AoS-type map and so far everything is going great. I have a copy of AoS Mithril that I'm using to see how the spawning system worked on that map. If you've never played it before, the basic idea is that there were barracks on the map that would spawn a preset set of units every 22 seconds. If you built special towers (like "knight towers" or "sorc towers") next to the barracks, they would spawn one additional unit of the type for each tower built. Mithril is my favorite AoS map and this system works great. I've been reading through the Mithril trigger comments and there was mention of changes made to improve performance. Now, there's definately a lot of bad ways to do this type of tower mediated spawning (for instance, the simplest way is doing a "Pick each unit in the region around the barracks, if unit == Knight Tower, Create 1 Knight at region" and doing that for all the barracks on the map, for all the different types of units you want to spawn. The guys who did Mithril had a better solution. For every barracks there is an int array that keeps track of the number of different unit spawn towers nearby. This list is updated when a tower is built or destroyed. At unit spawning time, they simply do a create TowerArray[x] units at region of barracks, where x is the array index of the particular unit type and TowerArray[x] holds the number of them to spawn (number of towers nearby). They then duplicated this code for all six barracks on their map. Now, I myself hate point click editting those little triggers (I know there are other options, but point and click is probably faster if you only kind of know what you're doing, which is where I am), so I came up with an even better solution that enables me to write a generic DoTowerMediatedSpawns function. Instead of having specific spawn functions for specific barracks on the map, my function can spawn units for a SpecifiedPlayer(variable) at a SpecifiedRegion(variable). I get around the lack of reference variables (pointers, or arrays of arrays) in the world editor by making a copy of the specific tower array I want to read and loading it into a generic tower work array that is used by my generic spawn function. This works great. The thing I'm worried about is that my way requires (NumberOfBarracks * NumberOfTowerSpawnedUnitTypes) more Integer copies (when I load my specific tower arrays into the generic holder) than the Mithril version of the spawning system. I was wondering if this is a problem. Even if I go crazy and have 10 barracks and 20 different unit types, that's only 200 extra Integer copies every 20 seconds. Any computer that can play WarCraft is not going to notice, so long as the trigger language compiles (I'm guessing that it does) What about performance over the network? Do all triggers increase network traffic? I can see it working both ways. I was hoping to get some feedback about how important it is to optimize trigger code for maps intended for multiplayer play on BNET. |
| 08-08-2003, 05:56 PM | #2 |
to my knowledge having all those arrays wouldn't make a big difference in terms of gameplay, but i have a pretty fast computer, so i dunno hmm, u can't make 2d arrays in jass? |
