I should have clarified when I said 'unit coordinate detection' because I meant using a non-EUD method such as
http://www.staredit.net/189419/ or "unit scanning" like in Elementa. So you don't need to worry about desyncs in the knockback system.
As for the EUD HP detection, it all depends on the implementation. Remember that you're detecting a value on the unitnode structure of a particular
unit index (that's what SCMDraft 2 calls it anyway), so that means the player of the unit doesn't matter. Just to clarify if you don't know the concept of the unit index, each unit in a StarCraft game is assigned a unique unit index regardless of the player. So the first unit placed on the map by StarCraft is assigned the unit index 0, the second unit placed is assigned unit index 1, etc. Your EUD HP detection trigger will detect the HP of a particular unit index, so it's not like you're detecting the HP of "Terran Marine owned by Player 4" or something like that. Here's where a problem arises though, let's say the player chooses his character and his unit is created onto the main arena. There's no trigger-efficient way to detect the unit index of this unit, because you never know if someone else already had his unit created or something else in the map created a unit so the unit index of the character is unknown, basically. Also if you want to make the character revive at some point, his unit index is even more hard to guess because chances are, the characters cast their spells which create and kill a significant amount of units. You may think that, let's say, there's a total of only 42 units on the map, and the next created unit will certainly be the unit index 42, but that is not always true due to how StarCraft works.
Here's a possible workaround. It's based on fact that as long as a unit never dies his unit index will stay the same. So, on the stage where the players select their characters, the units will be next to a beacon or something right? The idea is that when the player selects the unit, the unit is given to the player, and that unit is moved to the main arena and you know for certain which unit index it is (the latest version of SCMDraft 2 tells you this in the unit properties box dialog). Now what about if multiple players wanted to choose the same character? You can have 6 of each unit preplaced and you know their unit index (for aesthetics you can have 5 of them hidden and when a player selects that character, one is moved to the visible area). Another problem is that when that unit dies in battle you can't create another one because you don't know the unit index of the newly created one. A possible workaround is that you can make it so the unit is considered "dead" when it reaches below a certain HP (like 100), then you'd just move it offstage and you still know what the unit index is.
Now, the trigger count of this system alone would reach pretty high considering there are 6 players and 12 characters. Each character would need to be preplaced 6 times to handle all 6 players, so you need to detect the HP of (6 X 12) 72 units, and yes if you want to detect EVERY drop in HP then you need 1000 triggers for each unit if they have 1000 HP (72 X 1000 = 72000). This is considered an unmanageable amount (by my standards), so what you can do is either lower the HP for each unit, lower the amount of characters available, or make it so a character can only be selected once. Making each character selectable only once is probably the best solution in this case, as it would reduce the trigger count to 12000 which is still big, but manageable. With them activated with switches I don't think the lag would be too high, haven't tested it though.
Okay, location grids. The concept of the location grid is quite simple (though making it is not). I think the animated pictures in the wiki entry for location grids really shows the concept well if you haven't already looked at it:
Location Grids. Make sure you note the difference between pure and hybrid location grids and most importantly the benefits of location shifting. When I start a map with location grids, first I usually decide what kind of location grid I want with what accuracy, then I'd place the units/locations for that location grid and set up a location placement trigger system using it (not explained in the wiki, and yes I made that term up).
I'll provide an example. I tend to have the main arena in the center of the map with the dimensions either being 20x12 tiles or 20x10 (20x12 is considered to be the size of the visible area of the StarCraft screen including the hidden corner space in the HUD. 20x10 excludes the useless hidden HUD space). I'd usually have alot more accuracy, but for example's sake I'll make the accuracy at 32px (the size of a tile), and I'll make it a hybrid location grid because it saves a ton of locations and in most cases unit count isn't a problem, and I'll utilize location shifting. Now, generally we want to be as location-conservative as possible and willing to sacrifice other things to require less locations. We need to have the unit sequence going either in the X or Y direction, in this setup which would be more logical?
Right, the second one in the X direction because there's more units to cover more space of the arena and therefore less locations required. Now, in the pictures the units are placed in the arena itself to make it simpler, but in real maps you're gonna want them all the way in the bottom of the map or all the way in the right of the map, depending on which direction the units are going in. We want to do this to make full of use location shifting, which cuts our location count in half compared to if we didn't use it.
For the units themselves, they can be any units really, but the most convenient units are considered to be burrowable units because if we were doing a location grid with 2px accuracy, you can't stack non-burrowed units 2px from each other. There are a total of 10 burrowable units including spider mine, but we are going to not use spider mine because it can displace other burrowed units in more accurate hybrid grids (can be avoided though, but for simplicity's sake we won't) and we won't use zerg lurker because it sometimes doesn't fit nicely into a row of terrain. We are left with the eight other burrowable units, and we want to place them in sequential order and I'll discuss why later in the trigger section. Anyways, let's say that we need all 8 playable players in this map, so we don't want to place the units for players 1-8. We can, though, place them for players 9-12. The order that I usually use is to have the first 8 units for player 9 in this order: Zergling, Hydralisk, Drone, Defiler, Infested Terran, Devouring One, Hunter Killer, Unclean One, then have the next 8 in the same order but for player 10, then for players 11 and 12. So in my map I'd have a strip of walkable land in the very bottom with the units that look like so:
You should make use of SCMDraft 2's custom grid and unit copy and pasting functions. Remember they are 1 tile apart because we are doing a 32px grid.
With these units the X axis is covered in terms of the location grid, we just need to cover the Y axis which we'll do with locations that vary in the Y axis. Let's say we want to have a location that places something in this area:
We need to have a really long location whose middle is in that area when centered on one of our units. Also just an observation that the intersections of the 32px grid shown in that picture is a good representation of the points that the location grid will be able to place stuff in. Anyways this is what the location would look like:
So if that location was centered on the zerg zergling for player 9, and you created a wraith at that location, it would create it in the zone I mentioned earlier, you see? Now if I wanted to create a wraith at the square directly above that, I would increase the location's height by 2 squares. If you increase it by 2 squares, the center of the location increase by 1. You would just repeat this process of making locations until you reach the middle of the arena. When you do reach the middle of the arena, you'd notice that the height of the location is the height of the map. So if you wanted to cover the top half of the arena too, you'd make use of location shifting on your previously made locations.
Now you have the hybrid grid completely set up, and it covers the entire arena. Okay, but what use does this have? It only has the potential to place stuff in the entire arena, and the trigger system is what really puts it to good use. Here's how I almost always do my location grid triggers. First off for good practice, I dedicate a switch to the system, and each trigger in the system has a condition detecting if it's Set. I usually name it "_grid". I find it's best to look at the arena like a Cartesian coordinate system, so the most bottom-left of the grid is (0,0). Anyways we're going to need to utilize two death counters, I name them "_gridX" and "_gridY". Now, this trigger system assumes that "_gridX" and "_gridY" are set to the coordinates that we want to place a location in before the trigger system is run.
Okay, I thought I would have the motivation to write all this, but I don't. I've explained the basics so far, and the rest of this can be self-taught using examples and logic. I'll attach a map that I abandoned with what I've explained so far and with the trigger system, it uses a 1px hybrid grid on a 20x10. Another source of reference is my
Speed Tennis map, which I think is my best work with location grids yet. I know I haven't even touched on unit coordinate detection and heck even the linear math aspect to it, but try to think critically at how it would be done. A lot of this is better off being self-taught. Sorry if you were expecting a full explanation of the knockback system, maybe I'll write part 2 another day if I feel motivated enough.
Attachments:
Post has been edited 1 time(s), last time on Apr 19 2010, 5:05 am by yoonkwun.
None.