Staredit Network > Forums > SC1 UMS Theory and Ideas > Topic: [EUD] Unit Direction Detection
[EUD] Unit Direction Detection
Mar 21 2010, 10:45 pm
By: Cinolt  

Mar 21 2010, 10:45 pm Cinolt Post #1



Hopefully this isn't already too known :unsure:

For those who can't grasp the concept of unit direction detection through Kenoli's method or scanning, I've found a method to detect unit direction/facing detection through EUDs.

There's one byte on the unitnode structure that has the unit's direction. The higher the value of the byte the more the direction is offsetted in a clock-wise direction. For example, 0 would mean it's facing up, 64 facing right, 128 facing down, 192 facing left.

First value in the memory condition AKA the extended player:

Code
First unit:  19043
Second unit: 161759
Third unit:  161675
Fourth unit: 161591
Subtract 84 from the player to get the next consecutive unit.


The byte we want is offsetted in the fourth byte with the first three being non-zero values so we want to use two conditions with the same extended player but one being At Least and the second being At Most.

To get the At Least value you convert the direction value you want into hexadecimal, append six zeros after it, then convert it back to decimal:

40 00 00 00
1073741824

For the At Most value you do the same thing except append six F's after it:

40 FF FF FF
1090519039

Here is a list of 8 common directions:

Code
UP         (Direction Value 0)   - AtLeast 0,          AtMost 16777215
UP RIGHT   (Direction Value 32)  - AtLeast 536870912,  AtMost 553648127
RIGHT      (Direction Value 64)  - AtLeast 1073741824, AtMost 1090519039
DOWN RIGHT (Direction Value 96)  - AtLeast 1610612736, AtMost 1627389951
DOWN       (Direction Value 128) - AtLeast 2147483648, AtMost 2164260863
DOWN LEFT  (Direction Value 160) - AtLeast 2684354560, AtMost 2701131775
LEFT       (Direction Value 192) - AtLeast 3221225472, AtMost 3238002687
UP LEFT    (Direction Value 224) - AtLeast 3758096384, AtMost 3774873599
*It gets a bit iffy with the diagonals, you should include multiple directional values for them.


Memory addresses in case anyone is interested:

Code
First unit:  59CCF3
Second unit: 6282E3
Third unit:  628193
Fourth unit: 628043
Subtract 0x150 for the next consecutive unit.


Also, if you don't want to have triggers for all 256 directions you can use the AtLeast from a lower value and AtMost from another higher value.

Post has been edited 5 time(s), last time on Mar 23 2010, 8:11 pm by yoonkwun.



None.

Mar 21 2010, 11:54 pm TiKels Post #2



Ah thanks! I had asked one of the more EUD-savvy members about this awhile ago and they simply were unable and gave up, thanks! Though that was before I had really heard of kenoli's.



"If a topic that clearly interest noone needs to be closed to underline the "we don't want this here" message, is up to debate."

-NudeRaider

Mar 23 2010, 1:21 am stickynote Post #3



Wow, thanks. That saves a lot of time.



None.

Mar 23 2010, 6:42 am O)FaRTy1billion[MM] Post #4

👻 👾 👽 💪

Using At Most/At Least you can ignore the first 3 bytes.



TinyMap2 - Latest in map compression! ( 7/09/14 - New build! )
EUD Action Enabler - Lightweight EUD/EPD support! (ChaosLauncher/MPQDraft support!)
EUDDB - topic - Help out by adding your EUDs! Or Submit reference files in the References tab!
MapSketch - New image->map generator!
EUDTrig - topic - Quickly and easily convert offsets to EUDs! (extended players supported)
SC2 Map Texture Mask Importer/Exporter - Edit texture placement in an image editor!
\:farty\: This page has been viewed [img]http://farty1billion.dyndns.org/Clicky.php?img.gif[/img] times!

Mar 23 2010, 6:50 am Kaias Post #5



I don't mean to thread hi-jack, but does anyone know offhand EUDs for reading if a portrait is talking or not? Danke



None.

Mar 23 2010, 9:14 am rockz Post #6

ᴄʜᴇᴇsᴇ ɪᴛ!

I searched for that once and the current portrait being shown uses a pointer to a variable location, which means it's improbable to use that address. I don't think blizz would put in an "istalking" byte, but I could be mistaken.



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

Mar 23 2010, 7:50 pm Kaias Post #7



Quote from rockz
I searched for that once and the current portrait being shown uses a pointer to a variable location, which means it's improbable to use that address. I don't think blizz would put in an "istalking" byte, but I could be mistaken.
My objective is to manually substitute in new voices for specific units. An 'is talking' byte wouldn't have surprised me, simply because of the 'show portrait talking' and 'transmission' actions; in any case, it was simply a mean to that end. Right click detection and selection detection combined could achieve the desired effect, however, as far as I know right click hasn't been found (if it can be). If anyone has any bright ideas for another method, I'd love to hear it.

Post has been edited 1 time(s), last time on Mar 23 2010, 8:02 pm by Kaias. Reason: Typographical Error



None.

Mar 23 2010, 8:09 pm Cinolt Post #8



Quote from O)FaRTy1billion[MM]
Using At Most/At Least you can ignore the first 3 bytes.

Fixed. It should now work with terran infantry units just as well.



None.

Mar 23 2010, 9:17 pm Cinolt Post #9



Quote from Kaias
My objective is to manually substitute in new voices for specific units. An 'is talking' byte wouldn't have surprised me, simply because of the 'show portrait talking' and 'transmission' actions; in any case, it was simply a mean to that end. Right click detection and selection detection combined could achieve the desired effect, however, as far as I know right click hasn't been found (if it can be). If anyone has any bright ideas for another method, I'd love to hear it.

I don't know exactly what this bytes' function is, but I think this will do generally what you want. It's offsetted on the fourth byte and becomes non-zero when the unit was recently ordered. It seems to decrement gradually back to zero.

This detects unit specific data directly which means it will suffer latency unlike how normal units' voices play instantly. At least it works multiplayer.

Attachments:
[EUD] Order.scx
Hits: 14 Size: 51.22kb

Post has been edited 2 time(s), last time on Mar 23 2010, 9:41 pm by yoonkwun.



None.

Mar 23 2010, 9:49 pm Kaias Post #10



Quote from name:yoonkwun
I don't know exactly what this bytes' function is, but I think this will do generally what you want. It's offsetted on the fourth byte and becomes non-zero when the unit was recently ordered. It seems to decrement gradually back to zero.
The problem with this is that it reads true even for auto acquired commands (AKA if an enemy walked by and your unit decided to shoot it, it would return true). This is the same problem as trying to use morphling's destination detection.

Quote from name:yoonkwun
This detects unit specific data directly which means it will suffer latency unlike how normal units' voices play instantly. At least it works multiplayer.
Frankly, whether the data is shared or local doesn't make a difference to me. Either way the only actions that will result from it's detection will be local (IE Play wav) and consequently non-desyncing.



None.

Jul 23 2010, 3:54 am goobie Post #11



By first unit, second unit, etc. these are the positions of the unit in the game memory correct?

if you're killing the units off whose direction you want to detect and respawning them, i suppose the only way to match the correct unit with the correct detector numbers would be to know it's facing (by ordering it to move straight up?) and testing all 1700 units for whether they're facing upwards. And do this several times in different directions to try and weed out false positives.

Or is there a way to know which memory slot the next spawned unit will occupy?

Also, could someone direct me to an article on direction detection or kenoli's method or pixel grids? I keep reading about these things but I can't find any forum threads concerning them directly, only fleeting references to them in threads on topics where they might be applied.



There's got to be something more to life than being really, really, ridiculously good looking...

Jul 23 2010, 4:01 am O)FaRTy1billion[MM] Post #12

👻 👾 👽 💪

Quote from name:yoonkwun
Also, if you don't want to have triggers for all 256 directions you can use the AtLeast from a lower value and AtMost from another higher value.
This is a good idea. It would be really hard for a player to make their unit face an exact angle.

Quote from goobie
By first unit, second unit, etc. these are the positions of the unit in the game memory correct?
Correct.

Quote from goobie
if you're killing the units off whose direction you want to detect and respawning them, i suppose the only way to match the correct unit with the correct detector numbers would be to know it's facing (by ordering it to move straight up?) and testing all 1700 units for whether they're facing upwards. And do this several times in different directions to try and weed out false positives.
You could make them the first units on the map (I don't know if it is possible to "sort" units placed on the map ...) so they have the lowest possible entry. That way if any other units on the map die, they wont ruin it if you replace these units as soon as they die.



TinyMap2 - Latest in map compression! ( 7/09/14 - New build! )
EUD Action Enabler - Lightweight EUD/EPD support! (ChaosLauncher/MPQDraft support!)
EUDDB - topic - Help out by adding your EUDs! Or Submit reference files in the References tab!
MapSketch - New image->map generator!
EUDTrig - topic - Quickly and easily convert offsets to EUDs! (extended players supported)
SC2 Map Texture Mask Importer/Exporter - Edit texture placement in an image editor!
\:farty\: This page has been viewed [img]http://farty1billion.dyndns.org/Clicky.php?img.gif[/img] times!

Jul 23 2010, 4:47 am Cinolt Post #13



Quote from goobie
if you're killing the units off whose direction you want to detect and respawning them, i suppose the only way to match the correct unit with the correct detector numbers would be to know it's facing (by ordering it to move straight up?) and testing all 1700 units for whether they're facing upwards. And do this several times in different directions to try and weed out false positives.

A better method is to dedicate a predetermined area for this purpose, respawn the unit there and test each unit for that position. This way there'd be no false positives. Or if that's not possible then you can create the unit, give it to player 9 and test each unit's owner. You couldn't have any other units owned by player 9, of course. Generally this is trigger-extensive stuff depending on how much units there are, avoid it if possible.

Quote from goobie
Or is there a way to know which memory slot the next spawned unit will occupy?

No. It's not even reliable to assume that if there's only one unit on the map, it dies, and another is spawned, that it'd be the first unit index.

Quote from goobie
Also, could someone direct me to an article on direction detection or kenoli's method or pixel grids? I keep reading about these things but I can't find any forum threads concerning them directly, only fleeting references to them in threads on topics where they might be applied.

The EUD method technically is the only true direction detection; the other methods merely detect changes in unit position and infer direction from it. Honestly, I would recommend you use the EUD system over the others because it's a lot easier (with ProTRG it can be made by typing a single line without having to deal with EP's or adjusting the quantity value) and uses less triggers/locations. The only drawback is that you can't have the unit die (unless you use the method above), whereas the other methods it could.

There was a pretty good tutorial on location grids on the old SC1 wiki but it's inaccessible at the moment. Here's the source of Kenoli's method (I say don't bother with it): http://www.staredit.net/189419/

Post has been edited 2 time(s), last time on Jul 24 2010, 2:39 am by yoonkwun.



None.

Jul 25 2010, 8:33 am goobie Post #14



Quote from name:yoonkwun
Quote from goobie
if you're killing the units off whose direction you want to detect and respawning them, i suppose the only way to match the correct unit with the correct detector numbers would be to know it's facing (by ordering it to move straight up?) and testing all 1700 units for whether they're facing upwards. And do this several times in different directions to try and weed out false positives.

A better method is to dedicate a predetermined area for this purpose, respawn the unit there and test each unit for that position. This way there'd be no false positives. Or if that's not possible then you can create the unit, give it to player 9 and test each unit's owner. You couldn't have any other units owned by player 9, of course. Generally this is trigger-extensive stuff depending on how much units there are, avoid it if possible.

I thought maybe I'd place extra/backup units, enough that would they could be killable and not run out of them. Then I'd only need to make detection triggers for that set of units in the backup queue.
Or I could stack a bunch of mineral spots or w/e, take up the first 1600 spots in the unit memory so anything that respawns would be in the last 100, reduce my triggers that way. I figure to have the ability to test all 1700 units' direction I'd need 1700 triggers to detect which slot a unit would occupy, and 1700x(the number of directions i would want to use). Would Starcraft run that many triggers reliably/quickly?

Quote from name:yoonkwun
Quote from goobie
Also, could someone direct me to an article on direction detection or kenoli's method or pixel grids? I keep reading about these things but I can't find any forum threads concerning them directly, only fleeting references to them in threads on topics where they might be applied.

The EUD method technically is the only true direction detection; the other methods merely detect changes in unit position and infer direction from it. Honestly, I would recommend you use the EUD system over the others because it's a lot easier (with ProTRG it can be made by typing a single line without having to deal with EP's or adjusting the quantity value) and uses less triggers/locations. The only drawback is that you can't have the unit die (unless you use the method above), whereas the other methods it could.

There was a pretty good tutorial on location grids on the old SC1 wiki but it's inaccessible at the moment. Here's the source of Kenoli's method (I say don't bother with it): http://www.staredit.net/189419/

Thanks! Interesting stuff

PS. You're the man :cool:



There's got to be something more to life than being really, really, ridiculously good looking...

Jul 25 2010, 3:28 pm Roy Post #15

An artist's depiction of an Extended Unit Death

Quote from name:yoonkwun
It's not even reliable to assume that if there's only one unit on the map, it dies, and another is spawned, that it'd be the first unit index.
This.

Quote from goobie
I thought maybe I'd place extra/backup units, enough that would they could be killable and not run out of them. Then I'd only need to make detection triggers for that set of units in the backup queue.
Death can easily be faked. Why bother making all those triggers for backup units? Move unit, give to another player, create same unit at location, kill unit at location. Only problem is if they are right up against the edge of unwalkable terrain on the top or right side, there may be a unit placement error. You could create and then move a unit to the location to get rid of the error, but the problem of no unit death animation would persist. I think it's a small price, though.

Quote from goobie
I figure to have the ability to test all 1700 units' direction I'd need 1700 triggers to detect which slot a unit would occupy, and 1700x(the number of directions i would want to use). Would Starcraft run that many triggers reliably/quickly?
StarCraft is capable of running several thousands of triggers, but may lag based on trigger conditions. It will run 1700*X triggers just fine, unless they all check for a resource intensive condition, such as Bring. Check http://www.staredit.net/topic/11648/0/ for some information about lagging conditions. I think editors break above 65536 triggers, while StarCraft is still capable of running the map.

Edit: As far as the number of directions goes, it only makes sense to use the same number of directions as the number of rotations for the unit's sprite. For example, a Zergling has 16 different facing directions, so you wouldn't need more than 16 directions to check; it would be redundant.

Edit: I figured I would share my values for my direction system on Fireball.
Code
0       Up              At least 0               At most 225929599
1       Up-Right        At least 225929600       At most 471859199
2       Upright         At least 471859200       At most 707788799
3       Right-Up        At least 707788800       At most 943718399
4       Right           At least 943718400       At most 1279647999
5       Right-Down      At least 1279648000      At most 1495577599
6       Downright       At least 1495577600      At most 1751507199
7       Down-Right      At least 1751507200      At most 2087436799
8       Down            At least 2087436800      At most 2223413247
9       Down-Left       At least 2223413248      At most 2499342845
10      Downleft        At least 2499342846      At most 2805272445
11      Left-Down       At least 2805272446      At most 3001202045
12      Left            At least 3001202046      At most 3357131645
13      Left-Up         At least 3357131646      At most 3563061245
14      Upleft          At least 3563061246      At most 3798990845
15      Up-Left         At least 3798990846      At most 4134920445
0       Up              At least 4134920446      At most 4294967295

I had two triggers for 'Up' because the editor didn't like the idea of going from a negative to a positive with at least/at most. It works perfectly with a Zergling, although I would imagine there would be some tweaking for other units.

Post has been edited 2 time(s), last time on Jul 25 2010, 4:03 pm by Roy.




Jul 25 2010, 6:40 pm Cinolt Post #16



Quote from Roy
Death can easily be faked. Why bother making all those triggers for backup units? Move unit, give to another player, create same unit at location, kill unit at location. Only problem is if they are right up against the edge of unwalkable terrain on the top or right side, there may be a unit placement error. You could create and then move a unit to the location to get rid of the error, but the problem of no unit death animation would persist. I think it's a small price, though.

That would force the attack/death system to be trigger-based, but he might want it to be based on normal unit attacks. The alternative is to give the unit higher HP then desired, then detect when it's below a certain HP to determine it "dead". For instance, if a marine is to have 100 HP, you would give it 200 HP, and detect when its HP is below 100. Then you would move it, create the death animation, etc. It's not the best method in terms of aesthetics.

Quote from Roy
Edit: As far as the number of directions goes, it only makes sense to use the same number of directions as the number of rotations for the unit's sprite. For example, a Zergling has 16 different facing directions, so you wouldn't need more than 16 directions to check; it would be redundant.

It has 16 graphical directions, but its true direction is not dependent on its graphical direction but rather on the slope in which it was moved. Therefore if you want more accuracy in that respect it makes sense to detect more than 16 directions.



None.

Aug 5 2010, 6:40 pm samsizzle Post #17



I've been playing around with this for a while now and i cant get it to work for A Fenix (Zealot), Up works and all that but other directions are real buggy and dont seem to work right away.



None.

Aug 13 2010, 1:20 am Roy Post #18

An artist's depiction of an Extended Unit Death

Quote from samsizzle
I've been playing around with this for a while now and i cant get it to work for A Fenix (Zealot), Up works and all that but other directions are real buggy and dont seem to work right away.
An easy way to debug is to add a display text message action to each direction you're implementing, and then move the unit around. If it's facing one direction but detecting another, adjust the death numbers. That's what I did to tweak my unit of choice to a desired accuracy.

In theory, though, the slopes should not vary between units. If you're getting odd detections, verify that your triggers are properly set up.




Aug 13 2010, 1:44 am rockz Post #19

ᴄʜᴇᴇsᴇ ɪᴛ!

you can use a leaderboard to display the 4 byte variable you're reading. convert the EPD into EUD, then place the unitID + 228 into a "kills" leaderboard. Players 1-8 will be displayed, but 9-12 won't.



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

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[2024-4-14. : 9:21 pm]
O)FaRTy1billion[MM] -- there are some real members mixed in those latter pages, but the *vast* majority are spam accounts
[2024-4-14. : 9:21 pm]
O)FaRTy1billion[MM] -- there are almost 3k pages
[2024-4-14. : 9:21 pm]
O)FaRTy1billion[MM] -- the real members stop around page 250
[2024-4-14. : 9:20 pm]
O)FaRTy1billion[MM] -- look at the members list
[2024-4-12. : 12:52 pm]
Oh_Man -- da real donwano
da real donwano shouted: This is the first time I've seen spam bots like this on SEN. But then again, for the last 15 years I haven't been very active.
it's pretty common
[2024-4-11. : 9:53 pm]
da real donwano -- This is the first time I've seen spam bots like this on SEN. But then again, for the last 15 years I haven't been very active.
[2024-4-11. : 4:18 pm]
IlyaSnopchenko -- still better than "Pakistani hookers in Sharjah" that I've seen advertised in another forum
[2024-4-11. : 4:07 pm]
Ultraviolet -- These guys are hella persistent
[2024-4-11. : 3:29 pm]
Vrael -- You know, the outdoors is overrated. Got any indoor gym and fitness equipment?
[2024-4-10. : 8:11 am]
Sylph-Of-Space -- Hello!
Please log in to shout.


Members Online: Moose, Roy