The use of UnitRecords is almost identical to what we use now (BaseData.h), except that the UnitRecord/UnitBlock structures are created by Dynamix, and the other op2helper format by OPU.
A UnitRecord is defined much in the same way as you'd be accustomed to when using op2helper:
UnitRecord record_name_here[]=
{
{ unitType, X, Y, 0, orientation, weaponCargo, unknown, cargo, amount },
// a line of zeroes ends the list
{ mapNone, 0, 0, 0, 0, mapNone, 0, 0, 0 }
};
The
unknown above seems to be 16 (0x10) in all 3 demo's. I tried changing it to a different value, but it just gets reset 15 (0x0F) after the UnitRecord was used in the UnitBlock constructor. So i think it more of a return value from UnitBlock then it is an input param.
For
orientation, i've included a new enum (see below) that behaves differently then the Direction enum you use with TethysGame::CreateUnit.
enum Orientation
{
orE =0x00,
orSE=0x20,
orS =0x40,
orSW=0x60,
orW =0x80,
orNW=0xA0,
orN =0xC0,
orNE=0xE0
};
The UnitRecord itself does not have to be EXPORTed, but if you plan to use it with TethysGame::CreateUnitBlock you
MUST EXPORT the UnitBlock, so Outpost2.exe can find it; the same way you'd export trigger-functions, using my EXPORT directive (or the SCRIPT_API as defined in the SDK headers). Of course you could also just use the declspec directly, but be sure to include extern "C" so the compiler will not decorate the exported name with its type information as it normally does will all exported identifiers.
EXPORT UnitBlock block_name_here(record_name_here);
TethysGame::CreateUnitBlock(Player[xx], "block_name_here", 0);
I do not yet know what the third param does. Just leave it 0 for now.
The above instruction creates the units immediatly. If you want them to a group, this is not necessary; just use AddUnits:
FightGroup grp=CreateFightGroup(Player[xx]);
grp.AddUnits(block_name_here);