Err, isn't it obvious from the file/function names? (Ignore the first post).
Or you could try some nifty assembly for a better solution. Maybe just call that function I used directly, and do it like I did it in the first post.
Function prototype (for understanding purposes only):
Unit* CreateUnit(map_id unitType, int pixelX, int pixelY, int creatorIndex, map_id cargo, int unitIndex, bool bCenterInTile); // 0x004467C0 Returns 0 (NULL) when out of unit records
...
// Globals
extern Sheet sheet; // 0x0055B780
void __declspec(naked) CreateMeteor(int x, int y, int size)
{
__asm
{
push 1 // Arg7 - bCenterInTile = true
push 0 // Arg6 - unitIndex = 0
mov eax, [esp+0x8 + 0xC] // Param3 - int size
push eax // Arg5 - size
push 6 // Arg4 - creatorIndex = Gaia
mov eax, [esp+0x10 + 8]// Param2 - int y
shl eax, 5 // convert tileY to pixelY (y*32 = y * (2^5) = y << 5)
push eax // Arg3 - pixelY
mov eax, [esp+0x14 + 4]// Param1 - int x
shl eax, 5 // convert tileX to pixelX (x*32 = x * (2^5) = x << 5)
push eax // Arg2 - pixelX
push mapMeteor // Arg1 - unitType
mov ecx, 0x0055B780 // "this" pointer for the Sheet object
mov eax, 0x004467C0 // Load address of CreateUnit function
call eax // Call CreateUnit (return value is in eax, which is a unit pointer)
or dword ptr [eax + 0x44], 0xC000 // Set DisasterWarn flags 1 & 2
mov dword ptr [eax + 0x3C], 1 // Set timer down to 1 tick
ret // Return, leaving the caller to clean the stack (__cdecl)
}
}
Edit: Almost forgot to remove the 10 mark delay
Edit: Tested, and fixed 3 bugs. The parameters were read with reversed offsets, the parameter offsets were not accounting for the arguments being pushed onto the stack, and the memory writes defaulted to a single byte instead of a full dword.
Edit: Fixed another bug, which somehow didn't crash during initial testing. The __cdecl calling convention, which is the default for non member functions (i.e. "C" functions), requires the caller to clean the stack, not the callee.