I received a lot of good help on this code and eventually got it to load withou slic errors but still its not working as intended (in fact not at all). Can anyone provide some help on this?
My next bet is to change it from disband to sleep because maybe disband is causing the problem but sleep is kind of important in enemy territory.
Code:
HandleEvent(DisbandUnit) 'GiftUnit' pre {
unit_t tmpUnit;
location_t tmpUnitLoc;
int_t tmpUnitType;
int_t tmpWe;
int_t tmpThey;
unit_t tmpNewUnit;
tmpUnit = unit[0];
tmpUnitType = unit[0].type;
tmpUnitLoc = unit[0].location;
tmpWe = unit[0].owner;
tmpThey = CellOwner(tmpUnitLoc);
if (tmpThey > 0 && tmpThey != tmpWe) {
// Alternative options:
// if(HasAgreement(tmpWe, tmpThey, 36)) { // 36 = Military Pact
// if(HasAgreement(tmpWe, tmpThey, 38)) { // 38 = Alliance
if (!(AtWarWith(tmpWe, tmpThey))) {
KillUnit(tmpUnit);
CreateUnit(tmpThey, tmpUnitType, tmpUnitLoc, 0, tmpNewUnit);
}
}
}

. If that's the problem the solution would be to store the disbanded unit in variable -- maybe better create an array for keeping "gifted units" -- and create the correspondig unit during the receiver's turn.
Comment