I'm trying to adapt the sogdia rebellion code form the Alexander scenario. The scenario.slc code refers to a SwapCity function. The function in AG_func.slc is aso follows:
// Swaps City to Player. Kills all units first if flag is set to 1.
int_f SwapCity (city_t swCity, int_t swPlayer, int_t killUnits)
{
int_t i;
int_t tmpPlayer;
int_t tmpNum;
int_t numUnits;
int_t noSwap;
unit_t tmpUnit;
city_t tmpCity;
location_t tmpLoc;
tmpCity = swCity;
if (CityIsValid(tmpCity)) {
tmpPlayer = swPlayer;
numUnits = GetUnitsAtLocation(tmpCity.location);
tmpLoc = tmpCity.location;
for (i = 0; i < numUnits; i = i + 1) { // Check for special units
GetUnitFromCell(tmpLoc, i, tmpUnit);
tmpNum = tmpUnit.type;
if (tmpNum >= 72 && tmpNum <= 88) {
noSwap = 1;
}
}
if (noSwap == 0) {
if (killUnits == 1) {
for (i = 0; i < numUnits; i = i + 1) { //If no special units, kill all units
GetUnitFromCell(tmpLoc, i, tmpUnit);
Event: KillUnit(tmpUnit, 0, tmpUnit.owner);
}
}
Event:GiveCity(tmpCity, tmpPlayer);
} else {
return -1; // Can't swap due to Special unit
}
} else {
return -2; // Can't swap due to invalid city
}
}
Initially it threw up syntax errors when I used it. I assumed this was due to the special unit checks as I have no special units. But I can't seem to get it working. All I want is all player 1s units killed in the city and then the city swapped to player0.
Help!!!!
// Swaps City to Player. Kills all units first if flag is set to 1.
int_f SwapCity (city_t swCity, int_t swPlayer, int_t killUnits)
{
int_t i;
int_t tmpPlayer;
int_t tmpNum;
int_t numUnits;
int_t noSwap;
unit_t tmpUnit;
city_t tmpCity;
location_t tmpLoc;
tmpCity = swCity;
if (CityIsValid(tmpCity)) {
tmpPlayer = swPlayer;
numUnits = GetUnitsAtLocation(tmpCity.location);
tmpLoc = tmpCity.location;
for (i = 0; i < numUnits; i = i + 1) { // Check for special units
GetUnitFromCell(tmpLoc, i, tmpUnit);
tmpNum = tmpUnit.type;
if (tmpNum >= 72 && tmpNum <= 88) {
noSwap = 1;
}
}
if (noSwap == 0) {
if (killUnits == 1) {
for (i = 0; i < numUnits; i = i + 1) { //If no special units, kill all units
GetUnitFromCell(tmpLoc, i, tmpUnit);
Event: KillUnit(tmpUnit, 0, tmpUnit.owner);
}
}
Event:GiveCity(tmpCity, tmpPlayer);
} else {
return -1; // Can't swap due to Special unit
}
} else {
return -2; // Can't swap due to invalid city
}
}
Initially it threw up syntax errors when I used it. I assumed this was due to the special unit checks as I have no special units. But I can't seem to get it working. All I want is all player 1s units killed in the city and then the city swapped to player0.
Help!!!!
Comment