Get Unit ID To Unit Struct Pointer

Scripting particularly to improve NoX is discussed in here

Get Unit ID To Unit Struct Pointer

Postby panic » Tue Jan 14, 2020 12:48 am

this function will give unit struct pointer by unit id.

int UnitToPtr(int unit)

int unit
- valid id in native script of any unit.

- unit struct pointer address

Native Script Code::
Code: Select all
int ImportUnitToPtrFunc()
    int arr[10], link;
    if (!link)
        arr[0] = 0x50725068; arr[1] = 0x2414FF00; arr[2] = 0x511B6068; arr[3] = 0x54FF5000; arr[4] = 0xC4830424;
        arr[5] = 0x7230680C; arr[6] = 0xFF500050; arr[7] = 0x83042454; arr[8] = 0xC03108C4; arr[9] = 0x909090C3;
        CancelTimer(FrameTimerWithArg(10, ImportUnitToPtrFunc, ImportUnitToPtrFunc));
        link = GetMemory(GetMemory(0x75ae28) + (0x30 * GetMemory(GetMemory(0x83395c) + 8) + 0x1c));
    return link;

int UnitToPtr(int unit)
    int temp = GetMemory(0x5c336c), res;
    SetMemory(0x5c336c, ImportUnitToPtrFunc());
    res = Unknownb8(unit);
    SetMemory(0x5c336c, temp);
   return res;

You have to call 'ImportUnitToPtrFunc' function in MapInitialize before using.


- Nox Original (1.2b)
- script compiler with support memory read/write
Posts: 332
Joined: Thu Nov 12, 2015 3:47 pm

Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest