SCRMaps
/
Sign in

Writing one and two byte fields

A death trigger moves in four byte steps. Anything smaller needs a mask.

5 min read

EPD works in four byte units, so a one byte field - a unit's armour, its size class, its owner - cannot simply be written. Write the four bytes it sits in and you take the neighbouring three with it.

Remastered solved this when Blizzard added bitmask parameters to triggers. SetDeathsX and MemoryX are the ordinary ones plus a mask, and only the bits set in the mask are touched.

Which mask for which byte
0xFFThe first byte of the four - the lowest
0xFF00The second byte
0xFF0000The third
0xFF000000The fourth - the highest
0xFFFFThe lower two bytes
0xFFFF0000The upper two bytes

The value has to be shifted to where the mask points: to put 5 in the third byte, the value is 5 × 0x10000. This is what numbers like 228 * 65536 in the build queue code are - 65536 is 0x10000, and the second slot lives in the upper two bytes.

In epScript you rarely write a mask yourself - accessing a field by name, as in TrgUnit(u).armor, does the read-modify-write for you. You reach for masks by hand when the address has no name.

PTR and EPD
Sign in to track your progress