SCRMaps
/
Sign in

eudplib: memory, strings and maths

This is where what EUD can actually do lives.

8 min read

This is the heart of it: the functions that read and write game memory. The suffix on the name is what decides the performance.

  • _epd - addressed by EPD value. The general case.
  • _cp - addressed relative to Current Player. About twice as fast as _epd.
  • _safe - reads without touching the target memory at all, for places you cannot write. Twice as slow.
Reading memory
f_dwread_epd(targetplayer)Read a dword at an EPD location.
f_epdread_epd(targetplayer)Read an EPD value.
f_dwepdread_epd(targetplayer)Read the dword and the EPD together - the efficient way to follow a pointer.
f_dwread_cp(cpo) / f_epdread_cp(cpo) / f_dwepdread_cp(cpo)The same, relative to Current Player.
f_dwread_epd_safe / f_epdread_epd_safe / f_dwepdread_epd_safeSafe variants for read-only memory.
f_bread(ptr) / f_wread(ptr) / f_dwread(ptr)Read a byte, word or dword from a pointer.
f_flagread_epd(targetplayer)Read bit flags.
f_bitsplit(a)Split a dword into bits.
f_dwbreak(number) / f_dwbreak2(number)Break a dword into words and bytes; dwbreak2 keeps the place values.
Writing memory
f_dwwrite_epd(targetplayer, value)Write a dword at an EPD location.
f_dwadd_epd / f_dwsubtract_epdAdd and subtract.
f_dwwrite_cp / f_dwadd_cp / f_dwsubtract_cpThe Current Player forms.
f_bwrite(ptr, b) / f_wwrite(ptr, w) / f_dwwrite(ptr, dw)Write a byte, word or dword through a pointer.
f_memcpy(dst, src, copylen)Copy memory.
f_repmovsd_epd(dstepdp, srcepdp, copydwn)Block copy.
f_dwpatch_epd / f_blockpatch_epd / f_unpatchall()Patch memory, and undo every patch at once.
Current Player
f_getcurpl()Read Current Player - about 32 times faster than reading 0x6509B0 yourself.
f_setcurpl(cp)Set Current Player.
Strings
DBString(content)A string that does not consume the map's string table.
f_dbstr_print(dst, args...)Print several values into a string at once.
f_dbstr_adddw(dst, number)Append a number in decimal.
f_dbstr_addptr(dst, number)Append a number as eight hex digits.
f_dbstr_addstr(dst, src)Append a string.
f_simpleprint(args...)Print values straight to the screen. Good for debugging.
f_strcmp(s1, s2) / f_strcpy(dst, src)Compare and copy strings.
EUDByteReader() / EUDByteWriter()Read and write byte by byte.
Maths and randomness
f_mul(a, b) / f_div(a, b)Multiply and divide.
f_bitand / f_bitor / f_bitxor / f_bitnot / f_bitnand / f_bitnor / f_bitnxorBitwise operations.
f_bitlshift(a, b) / f_bitrshift(a, b)Bit shifts.
f_sqrt(n) / f_atan2(y, x) / f_lengthdir(length, angle)Square root and trigonometry, for working with coordinates.
f_rand() / f_dwrand() / f_srand(seed) / f_getseed() / f_randomize()The random number functions.
EUDBinaryMax(cond, minv, maxv) / EUDBinaryMin(...)Binary-search the largest or smallest value satisfying a condition.
Miscellaneous
f_playerexist(player)Whether a player is present. Works on Battle.net and UDP only.
f_getuserplayerid()Get your own player number.
QueueGameCommand(data, size)Queue a raw game command.
QueueGameCommand_Select(n, ptrList) / QueueGameCommand_RightClick(xy)Selection and right-click commands.
Sign in to track your progress