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.
| 0xFF | The first byte of the four - the lowest |
|---|---|
| 0xFF00 | The second byte |
| 0xFF0000 | The third |
| 0xFF000000 | The fourth - the highest |
| 0xFFFF | The lower two bytes |
| 0xFFFF0000 | The 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